Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Suggestion for capturing screen in full screen mode.



  • We need the suggestion for capturing screen in full screen mode.

    Following are the requirement we are trying to achieve :

    1. Application shall be in full screen mode – with no title bar. As it is full screen mode Windows task bar shall be not directly accessible.

    2. We need to capture the full screen mode screen as screenshot in one of the directory.
      We are using following code but actual screen is not captured. Instead, it captures white screen.

      QScreen *screen = QGuiApplication::primaryScreen();
              QPixmap pixMap = screen->grabWindow(0, 0,0,1920,1080);
      
      qDebug() << "Writing image to " << filename;
      
      QImage snapshot = pixMap.toImage();
      snapshot.save(“C:\\test, nullptr, 100);
      

    In Maximized mode it is working.

    Any pointers for the same will be great help.



  • http://doc.qt.io/qt-5/qscreen.html#grabWindow
    Using a magic number of 0 for the WID is probably not a good idea. I would use the QWidget::winId function to get the ID.

    Is this a QWidget? You could use grab from that to get a pixmap as well.


Log in to reply