How to take screen captures
I would like to use Qt's QWebEngine module to take screen captures from an URL. However, although the documentation section on
QWebEnginePage::printToPdf, it doesn't mention any way to save pages to image files.
Does anyone know if Qt's QWebEngine module can be used to take screen captures of websites?
I would not have thought so.Though I could be wrong. :)
You need to render the webEngineView:
QSize size(1024,800); view.resize(size); QImage image(size, QImage::Format_ARGB32); QPainter painter(&image); view->render(&painter); // render the webEngineView painter.end();
From my experience, the raw result is not very good, need a blurr effect.
@mpergand thanks for the help. I've managed to get a minimal working example to run based on your code snippet.
However, it appears that this approach involves creating a window. Is it possible to take a screenshot without opening a window?