1. 安装Qt 5.15.2 选择对应编译器和源码:
安装后已有pdf对应的库和源码:
将QtPdf和QtPdfWidgets目录拷贝到msvc2019_64/include(根据需要用到的编译器而定)
将C:\Qt\5.15.2\Src\qtwebengine\src\pdf\api所有文件拷贝到C:\Qt\5.15.2\msvc2019_64\include\QtPdf
将C:\Qt\5.15.2\Src\qtwebengine\src\pdfwidgets以下文件拷贝到
拷贝到:C:\Qt\5.15.2\msvc2019_64\include\QtPdfWidgets
测试:
使用Qt creator打开pdf例子程序:
2. 修改.pro 加入库和头文件:
INCLUDEPATH += C:/Qt/5.15.2/msvc2019_64/include/QtPdfWidgets
INCLUDEPATH += C:/Qt/5.15.2/msvc2019_64/include/QtPdf
LIBS += -LC:/Qt/5.15.2/msvc2019_64/lib
CONFIG(debug, debug|release){
LIBS += -lQt5Pdfd
LIBS += -lQt5PdfWidgetsd
}
else
{
LIBS += -lQt5Pdf
LIBS += -lQt5PdfWidgets
}