Deployed Qt5 Application Doesn't Print or Show Print Dialog

Posted by MustacheMcLimey on Stack Overflow See other posts from Stack Overflow or by MustacheMcLimey
Published on 2013-06-18T17:37:47Z Indexed on 2013/07/03 17:05 UTC
Read the original article Hit count: 646

Filed under:
|
|
|

I'm experiencing Qt4 to Qt5 troubles. In my application when the user clicks the print button two things should happen, one is that a PDF gets written to disk (which still works fine in the new version, so I know that some of the printing functions are working properly) and the other is that a QPrintDialog should exec() and then send to a connected printer.

I see the dialog when I launch from my development machine. The application launches on the deployed machine, but the QPrintDialog never shows and the document never prints.

I am including print support.

QT += core gui network webkitwidgets widgets printsupport

I have been using Process Explorer to see what DLLs the application uses on my development machine, and I believe that everything is present. My application bundle 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 ]

The following is the relevant 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 relevant DLLs are not being found come print time, and that means that my application file system is incorrect, but I have not found anything that shows me a different file structure. Am I on the right track or is there something else wrong with this setup?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about deployment