Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebEngineView screenshot
Qt 6.11 is out! See what's new in the release blog

QWebEngineView screenshot

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CKurduC Offline
    CKurduC Offline
    CKurdu
    wrote on last edited by
    #1

    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?

    You reap what you sow it

    jsulmJ 1 Reply Last reply
    1
    • CKurduC CKurdu

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • CKurduC Offline
        CKurduC Offline
        CKurdu
        wrote on last edited by
        #3

        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.

        You reap what you sow it

        jsulmJ 1 Reply Last reply
        0
        • CKurduC CKurdu

          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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • CKurduC Offline
            CKurduC Offline
            CKurdu
            wrote on last edited by
            #5

            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?

            You reap what you sow it

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved