Unsolved QWebEngineView screenshot
-
Hi Everyone,
I am getting a screenshot from a website by using QWebEngineView with below code.QImage* image = new QImage(width,height,QImage::Format_ARGB32); QRegion rg(left,top,width,height); QPainter painter(image); this->wview->show(); this->wview->page()->view()->render(&painter,QPoint(),rg); painter.end(); QByteArray ba; QBuffer bu(&ba); bu.open(QBuffer::ReadWrite); image->save(&bu, "JPG",80); item->setVisible(true); QString imgBase64 = ba.toBase64(); bu.close();
But my problem is that it is only possible when my widget is visible. It is neccessary to get screenshot when the widget is hidden.
How can I get a screenshot of a web page that is inside a hidden window?
-
@CKurdu Why don't you simply get the page using http://doc.qt.io/qt-5/qwebengineview.html#page and then save the page using http://doc.qt.io/qt-5/qwebenginepage.html#save ?
-
My project is that capturing any area from any web page that has live data then presents as pictures on smart tv. Because smart tv is not capable of showing every HTML code correctly and also we need the only specific area of a webpage, I don't think QWebEnginePage::save method solves my problem.
-
@CKurdu said in QWebEngineView screenshot:
Because smart tv is not capable of showing every HTML code correctly
Is your app running on a smart TV?
-
No, my application is running on PC with server role, then it sends the image data according to a configurable time interval to my other client application that runs on smart tv gets the picture via WebSocket connection than presents on the screen according to a layout.
I solved the problem by overriding 'showevent' and 'closeevent' for my widget. I ignore the close event then move the out of screen then later when the program gets 'showevent' , it moves the first position.
I think the the solution is not good for optimization. Maybe another way?