Problem fixed in Qt5.3
Qt 5.3 Print Support
- New QPA class QPlatformPrintDevice to abstract platform print device hardware, new implementations for Windows, Mac and Linux.
- QPrinterInfo provides more details on the print device hardware
- QPrinter uses QPageSize and QPageLayout to improve page layout handling
- QPrinter has had the behaviour of most functions standardised across all platforms (as detailed below)
- Mac can now have each painted page with a different orientation, and can set Collate Copies and Document Name.
- Mac and Windows now support setting Document Creator and Duplex Mode
- Mac and Linux now support using Windows Page ID (DMPAPER values)
- Linux now requires CUPS 1.4 (RHEL 5 no longer supported)
Code tested in Windows:
QPrinter print(QPrinter::HighResolution);
print.setPageMargins(qreal(1), qreal(1), qreal(1), qreal(1), QPrinter::Millimeter);
print.setPaperSize(QPagedPaintDevice::A4);
QPrintPreviewDialog pd(&print, mwindow, Qt::Window);
QObject::connect(&pd, SIGNAL(paintRequested(QPrinter *)), this, SLOT(preview(QPrinter *)));
if(pd.exec() == QPrintPreviewDialog::Accepted) {
/*something*/
}
...
void MainWindow::preview(QPrinter* p) {
mframe->print(p);//mframe is an QWebFrame
}