Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Which method is used to show a print preview for a web page?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved QtWebEngine
1 Posts 1 Posters 593 Views 1 Watching
  • 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 Offline
    B Offline
    Bui Trung
    wrote on last edited by Bui Trung
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved