Qt5 deployed application does not print or display print dialog

I am having Qt4 issues before Qt5. In my application, when the user presses the print button, two things should happen: one is that the PDF file is written to disk (which still works fine in the new version, so I know that some of the printing functions work properly), and another that QPrintDialog should execute exec (), and then send it to the connected printer.

I see a dialog when I start from my development machine. The application runs on a deployed machine, but QPrintDialog never displays and the document never prints.

I turn on print support. A.

QT += core gui network webkitwidgets widgets printsupport 

I use Process Explorer to find out which DLL applications are using on my development machine, and I believe that everything is present. My application package includes:

  • {myAppPath} \ MyApp [MyApp.exe, Qt5PrintSupport.dll, ...]
  • {myAppPath} \ Plugins \ printsupport \ windowsprintersupport.dll
  • {myAppPath} \ plugins \ imageformats [qgif.dll, qico.dll, qjpeg.dll, qmng.dll, qtga.dll, qtiff.dll, qwbmp.dll]

Below is the corresponding code snippet:

 void PrintableForm::printFile() { //Writes the PDF to disk in every environment pdfCopy(); //Paper Copy only works on my dev machine QPrinter paperPrinter; QPrintDialog printDialog(&paperPrinter,this); if( printDialog.exec() == QDialog::Accepted ) { view->print(&paperPrinter); } this->accept(); } 

My first thought is that the corresponding DLLs were not found, the print time, and this means that my application file system is incorrect, but I did not find anything that shows me a different file structure. Am I on the right track or is there something else wrong with this setting?

+4
source share
1 answer

This was another classic Windows / Qt5 deployment issue with a combination of missing plugins and plugins placed in the wrong places. Using the QT_DEBUG_PLUGIN environment variable and adding CONFIG + = CONSOLE to my PRO file, I could see that on my development machine the application was loading qminimal.dll, which I did not send.

The root of the application, which I defined as {myAppPath} \, is the root directory for the plugins. Therefore, the correct file structure:

  • {myAppPath} \ MyApp [MyApp.exe, Qt5PrintSupport.dll, ...]
  • {} \ myAppPath platform [qwindows.dll, qminimal.dll]
  • {myAppPath} \ printsupport *
  • {myAppPath} \ imageformats *
  • {myAppPath} \ media *

Thanks Peppu for leadership.

+6
source

Source: https://habr.com/ru/post/1486886/


All Articles