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,