Results 1 to 5 of 5

Thread: How to create screenshot of webpage in ui->webView ?

  1. #1
    Join Date
    Nov 2012
    Posts
    16
    Qt products
    Qt4

    Default How to create screenshot of webpage in ui->webView ?

    How to create screenshot of webpage in ui->webView ?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to create screenshot of webpage in ui->webView ?

    What have you read and tried?
    Do you mean screen shot of the currently visible portion of the page or a 'screenshot' of the page from top to bottom?

  3. #3
    Join Date
    Nov 2012
    Posts
    16
    Qt products
    Qt4

    Default Re: How to create screenshot of webpage in ui->webView ?

    I need a 'screenshot' of the page from top to bottom

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to create screenshot of webpage in ui->webView ?

    You can QWebView::print() the page into a PDF.
    You can access the QWebFrame and use QWebFrame::render() to paint the frame into a QImage. There's even an example in the QWebPage documentation.

  5. #5
    Join Date
    Nov 2012
    Posts
    16
    Qt products
    Qt4

    Default Re: How to create screenshot of webpage in ui->webView ?

    ChrisW67,

    This is programm:
    qwebview.jpg
    this code:
    void MainWindow::grabScreen(){
    QImage *image = NULL;
    QPainter *painter = NULL;

    int m_width = 800;
    int m_height = 800;

    do
    {
    image = new QImage(m_width, m_height, QImage::Format_RGB32);
    if(image == NULL)
    {
    qDebug("ERROR: Unable to create image.");
    break;
    }

    painter = new QPainter(image);
    if(painter == NULL)
    {
    qDebug("ERROR: Unable to create painter.");
    break;
    }

    QWebPage *page = ui->webView->page();
    QWebFrame *frame = page->mainFrame();

    qDebug("render");
    frame->render(painter);

    image->save("test.jpg", "JPG", 100);
    qDebug("saved.");
    }
    while(false);

    delete painter;
    delete image;
    }
    Give me a this result:
    test.jpg

    How can i get fullpage to image?
    Last edited by lapdx; 17th November 2012 at 22:46.

Similar Threads

  1. Screenshot with no show
    By mpi in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2011, 11:12
  2. Don't redraw desktop, use a screenshot instead.
    By danciac in forum Qt Programming
    Replies: 2
    Last Post: 8th September 2010, 11:40
  3. Take a screenshot and convert it to PNG but FAST !
    By fitzy in forum Qt Programming
    Replies: 11
    Last Post: 4th November 2009, 08:20
  4. Take a screenshot of a QGraphicsRectItem
    By yazwas in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2009, 13:14
  5. Screenshot
    By graciano in forum Qt Programming
    Replies: 3
    Last Post: 19th April 2009, 16:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.