Question

Bug in Qt5.2.1:

The only problem was corrected in QPrintPreviewDialog but when the print is printed on paper the failure still exists.

With QPrintPreviewDialog pages work perfect, but on "paper" (printed in paper) from second page (in other words all pages except the first occur the BUG) "texts" and "images" (non-background) disappear (apparently the fault only occurs with inline elements).

See: https://bugreports.qt.io/browse/QTBUG-37240 (see the attachments to a test-case)


Bug in Qt5.0.1, Qt5.0.2 and Qt5.1.0

The first page of the print out of a QWebView with small fonts and images.

Apparently the problem only occurs with inline elements (texts and images).

Note: The error occurs in Windows XP, Windows 7, Window 7 x64, Mac OS X 10.8.3

[edit]

Source-html: http://jsfiddle.net/bdm6Y/2/

Frame content: http://jsfiddle.net/bdm6Y/2/show/

ErrorPrint

Source:

QPrinter p;
p.setPaperSize(QPrinter::A4);
p.setFullPage(true);
p.setResolution(300);
p.setOrientation(QPrinter::Portrait);

QPrintPreviewDialog preview(&p);
preview.setWindowTitle(ui->myWebView->page()->mainFrame()->title());
connect(&preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printPreview(QPrinter*)));
preview.exec();

...

void printPreview(QPrinter *printer) {
    ui->myWebView->print(printer);
}

I do not know if this is a bug or something I did wrong, what could it be?

Thanks!

[edit]

QT bug reports:

https://bugreports.qt.io/browse/QTBUG-30621

Was it helpful?

Solution

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top