QPrinter problem QT 5.9.2 and 5.8
-
Hi everyone,
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 theQT
variable 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
-
Hi
QT += printsupportand
#include <QPrinter>does it for me on Qt 5.9/win 10.
-
Hi
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. -
@Krasnoiark
That sounds pretty ok.Can you try this default project and tell if it also gives errors?
https://www.dropbox.com/s/wxcdigflnwbeq4d/myprinter.zip?dl=0Also, 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
-
@Krasnoiark
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.
-
Hmm
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. -
https://drive.google.com/file/d/0B3foRMnUz_jLM1FPTVZZb1U2LUE/view?usp=sharing
This is my .pro file
-
@Krasnoiark You still add gui twice.
Do you have other Qt installations on your machine? -
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
$$files(.cpp)
$$files(classes/.cpp)
$$files(gui/*.cpp) \find something we dont expect and include.