How to create screenshot of webpage in ui->webView ?
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?
I need a 'screenshot' of the page from top to bottom
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.
ChrisW67,
This is programm:
qwebview.jpg
this code:Give me a this result: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;
}
test.jpg
How can i get fullpage to image?
Last edited by lapdx; 17th November 2012 at 22:46.
Bookmarks