Important: Please read the Qt Code of Conduct -

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);
        QByteArray ba;
        QBuffer bu(&ba);;
        image->save(&bu, "JPG",80);
        QString imgBase64 = ba.toBase64();

    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?

  • Lifetime Qt Champion

    @CKurdu Why don't you simply get the page using and then save the page using ?

  • 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.

  • Lifetime Qt Champion

    @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?

Log in to reply