QPrinter problem QT 5.9.2 and 5.8
I am a beginner in QT, And I have been stuck for weeks searching and searching everywhere but I can't resolve it.
I am only trying to use QPrinter in order to print a QTextDocument. I am working on QT 5.8 (I have switch to 5.9.2 still same problem)
I have added to my .pro file QT += printsupport
And included where I want to use QPrinter : #include <QtPrintSupport/QtPrintSupport>
(I have tryed including all of the classes).
The result is that I get undefined reference to `_imp___ZN8QPrinterD1Ev'.
When I manualy add #define QT_NO_PRINTER I get 'Orientation' in 'class QPrinter' does not name a type QPrinter::Orientation orientation() const;
I have tryed everything. Please can someone help me, I need PDF extraction and landscape oriantation for my QTextDocument.
Hi and welcome to devnet,
What OS are you running on ?
What compiler are you using ?
Did you re-run qmake after modifying the
QTvariable content ?
Hi, I am running on Windows 10 and Ubuntu 17 LTS.
I am using Mingw32 compiler.
I have run qmake after adding my QT variable, I have also deleted the build file, re-run the qmake and re built and same errors.
This is my code and the .pro file
QT += printsupport
does it for me on Qt 5.9/win 10.
Thanks for the response but it tells me that QPrinter is no such file or directory. Won't let me compile.
@Krasnoiark How did you install Qt?
I went on the QT website, downloaded the open source installer.
Downloaded and Installed QT 5.9.2 MinGW 5.3.0 32 bit. And I checked all the tools.
That sounds pretty ok.
Can you try this default project and tell if it also gives errors?
Also, you are targeting Desktop, correct ?
Its not bare metal project or something like that?
@Krasnoiark Most probably not the reason for the problem, but why do you add core and gui twice to QT?
It compiles and there is no errors
So i think your .pro or kit selection might be messed up.
This is a desktop app, correct?
Yes, this is a Desktop project and the project is a QTWidget project insite 2 other QT Sub-projects.
It does look fine with the kit.
It must be something with the pro file then
Since the test project worked and I assume you compiled that
exactly like this.
This is my .pro file
@mrjj I believe that once in the past you told me to try deleting the build folder. It has solved many of my problems, is it worth a try?
@Krasnoiark You still add gui twice.
Do you have other Qt installations on your machine?
its always worth a try :) Especially when stuff are strange. Good call.
@ofmrew No I don't. All I have is QT 5.9.2 MinGW and the tools
I have tryed recompiling from scratch, it did not work.
It seems not to be the pro file as
it is pretty basic and it could compile my project too.
And QPrinter is included in the installation as a default project works.
My best bet is that the
find something we dont expect and include.
@mrjj I have tryed retyping all the pro file with all the files included but no luck.
Do you think it could be about the multiple projects ? I have my software project inside a sub-project inside an other sub-project. (My team needed multiple projects in order to have the testing project and the software and a 2nd project because our project has multiple softwares ).
In the sub project I only include the projects it gathers. Should I include qprintsupport inside that pro file ?
If the sub projects also have .pro file
and you get the linker error in them/related to those files
then yes, you need
QT+=printsupport there also to link the module to that set of .o files.
OK THAT WAS IT ! I had to include inside the pro files the QT += printsupport.
Thank you for helping me and sorry for taking your time. It was pretty stupid of me not to check that.
Anyway, thank you.
No problem at all.
I also learn something :)
I had no idea you could do