Looking for help with QPrinter
-
Hello there.
I'm struggling to get QPrinter to work in my project and I'm hoping someone can point me in the right direction.
When I build the project I get "'QPrinter' was not declared in this scope". That's basically all I get for errors.
Within my .cpp file where I'm making a QPrinter object I have:
#include <QPrinter>In my .pro file I have:
QT += printsupportDoes anyone have any tips around what I can try to debug this?
-
Hello there.
I'm struggling to get QPrinter to work in my project and I'm hoping someone can point me in the right direction.
When I build the project I get "'QPrinter' was not declared in this scope". That's basically all I get for errors.
Within my .cpp file where I'm making a QPrinter object I have:
#include <QPrinter>In my .pro file I have:
QT += printsupportDoes anyone have any tips around what I can try to debug this?
@Stewguy said in Looking for help with QPrinter:
QPrinter
Hi,
first of, did you rerun qmake / delete your build folder for a clean rebuild after adding QT += printsupport ?
this is the most common error people havesecond,
for what platform do you try to use the modul for, IIRC I tried to use it to create a pdf on mobile devices and I had to fall back toQPdfWriter
-
Hello there.
I'm struggling to get QPrinter to work in my project and I'm hoping someone can point me in the right direction.
When I build the project I get "'QPrinter' was not declared in this scope". That's basically all I get for errors.
Within my .cpp file where I'm making a QPrinter object I have:
#include <QPrinter>In my .pro file I have:
QT += printsupportDoes anyone have any tips around what I can try to debug this?
-
You could try out one of the examples that uses QPrinter, e.g. the Font Sampler. If you have trouble there as well, it's probably a system or Qt configuration issue. If not, it's probably something in your project.
-
You could try out one of the examples that uses QPrinter, e.g. the Font Sampler. If you have trouble there as well, it's probably a system or Qt configuration issue. If not, it's probably something in your project.
@Asperamanca said in Looking for help with QPrinter:
You could try out one of the examples that uses QPrinter, e.g. the Font Sampler. If you have trouble there as well, it's probably a system or Qt configuration issue. If not, it's probably something in your project.
Thanks for pointing out the example, it ended up leading me to the solution.
What resolved it:
The QT template added the following lines into my .pro file
INCLUDEPATH += $$PWD/../../../../Qt/5.11.0/winrt_x86_msvc2017/include
DEPENDPATH += $$PWD/../../../../Qt/5.11.0/winrt_x86_msvc2017/includeSomething about those was causing QPrinter not to load. Once I removed those lines the project was able to Build and Run.
Thanks for the help everyone!