How to convert webpage content into images in qtwebkit

Source: Internet
Author: User

How to convert the rendering result in WebKit, that is, the webpage image to an image
You can use the image capture software, but if you want to use QTCodeThe principle is also very simple, that is, to render WebKit to an image, rather than a control.
The Code is as follows:
Qsize size = m_page.mainframe ()-> contentssize (); // size of the webpage
Image = qimage (size, qimage: format_argb32_premultiplied );
Image. Fill (QT: transparent); // do not set the background

// Render the web page
Qpainter P (& image); // The Key is here. When creating a painter, qimage is used instead of qwidget,
P. setrenderhint (qpainter: antialiasing, true );
P. setrenderhint (qpainter: textantialiasing, true );
P. setrenderhint (qpainter: smoothpixmaptransform, true );
M_page.setviewportsize (m_page.mainframe ()-> contentssize ());
M_page.mainframe ()-> render (& P );
P. End ();
Qimage stores the images of the entire web page,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.