QPrinter issues
-
Hey guys,
So I am having a strange issue where QPrinter works fine in one qt project and doesn't in the other. I am using Qt 5.10 ( I am tempted to say it is NOT the version but it could be).
I made a simple project which basically runs this chunk of code just fine.
QPrinter myPrinter; if (myPrinter.isValid()) { qDebug() << myPrinter.printerName(); QTextDocument doc("Test page!\nAnother Line!"); doc.print(&myPrinter); } qDebug() << QPrinterInfo::availablePrinterNames();
It prints a few lines to the default printer. Later I print out all available printers to check some things and look at what APrinterInfo has to offer. That is basically all it does it is a blank application project where i run this in main window constructor.
My other project essentially runs the same code but cannot seem to not find my printers and I am not sure why. The printer name is blank. The available printer list empty. No default printer exists either. I have the printsupport added to the .pro file in both projects, if I didn't simply adding the printer includes would not work. It is also the same machine so it should see the same printers.
I will be actively working to resolve this issue but if there are any pointers/ideas I would greatly appreciate it.
Thanks,
Shawn -
Hi,
Let's start by a maybe silly question: are you using the same kit to build both applications ?
Are you starting both from Qt Creator ? -
Then I'd check for differences in the environment variables in the build and the run parts of the Project panel.
-
Do you mean it happens if you run both application at the same time ?
What OS are you running ?
-
I run them at different times. What I mean is that I can open the serial resource in a test program (and fail to close it when the program ends) and any other call to open the serial resource will claim its in use until the resource is closed. I am wondering if this behaves in a similar manner.
I made the small one to test how to print things, then I basically added the code to my other project after I figured it out. In my test project it worked fine. Now in my other project it doesn't work. I can run the test one at any time and it works.
Windows 7 pro
-
How are you handling the printing in your big project ? What is different than from your small project ?
-
The good news is I got it working!
@SGaist not sure if you have insight as to why but I did do clean, ran qmake, and build several times. In the end I changed the build directory to be totally fresh. When I did that and rebuilt into the new directory it worked just fine.
@SGaist Thanks a lot for helping, I appreciate it!