Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    QtWebEngine
    1
    1
    497
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Bui Trung last edited by Bui Trung

      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);
          painter.setWindow(this->rect());
          this->render(&painter);
      }
      

      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.
      1 Reply Last reply Reply Quote 0
      • First post
        Last post