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 lists QWebEnginePage::print and 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?

  • @rmam
    I would not have thought so. Though I could be wrong. :)

  • You need to render the webEngineView:

    QSize size(1024,800);
    QImage image(size, QImage::Format_ARGB32);
    QPainter painter(&image);
     view->render(&painter);  // render the webEngineView

    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?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.