I'm having some troubles with printing under Windows. I'm setting a qprinter via a qprintdialog and pass the qprinter to a method which creates a qpainter on the qprinter. Essentially:
Qt Code:
  1. void functionA()
  2. {
  3. QPrinter printer;
  4. printer.setColorMode( QPrinter::Color );
  5. printer.setOrientation( QPrinter::Landscape );
  6. QPrintDialog printDialog( &printer, this );
  7. if ( printDialog.exec() != QDialog::Accepted )
  8. return;
  9. print( printer );
  10. }
  12. void print( QPrinter &printer )
  13. {
  14. printer.setOutputFormat( QPrinter::PdfFormat );
  15. printer.setPaperSize( _gttPrintDialog->pdfPaperSize() );
  16. printer.setFullPage( true );
  17. QPainter painter( &printer );
  18. // ...work with the painter...
  19. }
To copy to clipboard, switch view to plain text mode 

This results in no printout under Windows but under Linux there are no problems. Additionally, as soon as I define the printer inside print(...) everything works like a charm. Sadly, this is no permanent option and it seems like QPrinter can neither be passed by value nor can be copied to a local variable.
What's the reason for this behavior under Windows and is there any solution simpler than passing qpainters instead of qprinters and restructer the whole call tree of paint(...)?