QPrintSupport - print dialog not showing in windows
-
Greetings,
I have recently ran into a problem with QT5 and QTPrintSupport. I am using Qt version 5.15.0 with C++ on Windows 10, developing with Visual Studio 2019. I have QTPrintSupport set up in my project. When I build app in Debug or Release directly from Visual Studio, print dialog is called correctly and I can print whatever I want. If I then open the build folder and run the .exe file directly, print dialog window is not shown. We usually install the app using ClickOnce technology. When I run the app directly from windows (using the installed ClickOnce), that does not work either.std::ofstream printDebug("print.txt"); printDebug << "creating print dialog" << std::endl; QPrintDialog printDialog(&printer, this); if (printDialog.exec() != QDialog::Accepted) return;
the print out is called every time so the code correctly reaches the lines with QPrintDialog. Do you have any clue what could be wrong here?
Thanks in advance,
Kosmic -
Hi
It could be missing windowsprintersupport.dll or it sees the wrong version.
also could be the deployment folder that is not having the right layout.
I think the windeployqt also makes a folder called printsupport but not 100% sure. -
Recently, I have discovered that from Visual Studio, when printing:
printDebug << QPrinterInfo::availablePrinters().size() << std::endl;
It has discovered 7 printers available. When I print this from the deployment folder, it will print 0. Can this be connected to the dll not registered by the application?
-
Finally discovered the error here. Inspired here:
https://forum.qt.io/topic/39319/solved-qprinterinfo-availableprinters-don-t-list-available-printers/2
the .dll file was from the previous version before upgrade and somehow didnt get upgraded along. So copying the file manually to the location instead of the previous dll version made it.
Thanks for help,
Kosmic