Qt Cannot open include file: 'QPrinter'

2019-02-21 10:52发布

I am new to Qt. Downloaded source code for a Qt application of SourceForge, and tried to build and run it. After working through a few similar problems by adding QT += statements to .pro files, I am stuck on this one:

On attempting to build in Qt Creator, I get errors saying

error: C1083: Cannot open include file: 'QPrinter': No such file or directory

I tried adding QT += printsupport to the .pro file, cleaning, and rebuilding, but that gives this error

Error: dependent '..\..\..\..\..\..\..\..\..\..\..\Qt\Qt5.1.1\5.1.1\msvc2012_64\include\QtPrintSupport\qtprintsupportglobal.h' does not exist."

When I go to C:\Qt\Qt5.1.1\5.1.1\msvc2012_64\include\QtPrintSupport, qtprintsupportglobal.h IS THERE!

标签: qt include qmake
2条回答
干净又极端
2楼-- · 2019-02-21 11:04

In my case the solution was to

Delete the shadow build directory and build again

after adding printsupport, as @KubaOber suggests in the comments.

查看更多
Juvenile、少年°
3楼-- · 2019-02-21 11:26

You have to add QPrinter Support to your project's .pro file:

QT += printsupport
查看更多
登录 后发表回答