Which method is used to show a print preview for a web page?

  • I know this is an common question, but this time i can't solved it.
    I want to show a print preview of of a web page ( which long is more than 2 pages) and Qt support class QPrintPreviewDialog to do this task . In the earlier version of Qt i only need to connect the "paintRequest" SIGNAL with the QWebView::print SLOT and it'll be done correctly.
    But in the version of Qt 5.7 (and now 5.8 beta) i can't use this method anymore because it have been removed.
    I have implemented my own SLOT to show the preview of a web page(which is connected to the paintRequest SIGNAL). The following is what i did:

    // print preview current page
    void WebView::printPreview(QPrinter *printer){
        QPainter painter(printer);

    With the web page long one screen then everything is well. But when the web page is too long, it only shows a partial of the web page with a scroll bar.
    Anyone has any idea or solution for it? Thanks.

    • You can import an sample of demo browser in Qt 5.8 beta to be an example of this case.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.