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. How to take snapshot of the whole GUI
Forum Updated to NodeBB v4.3 + New Features

How to take snapshot of the whole GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 6 Posters 2.8k Views 2 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.
  • J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #3

    Hi,

    QPixmap *pixmap = new QPixmap(this->size());
    this->render(pixmap);
    

    inside your Gui-Class should do the trick.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qt Enthusiast
      wrote on last edited by
      #4

      For Mainwindow

      D 1 Reply Last reply
      0
      • Q Qt Enthusiast

        For Mainwindow

        D Offline
        D Offline
        Devopia53
        wrote on last edited by
        #5

        @Qt-Enthusiast

        I would like to take snapshot of the whole GUI

        If this means to include window frames, try this:

        void Mainwindow::screenShot()
        {
            QRect   geo = frameGeometry();
            qApp->primaryScreen()->grabWindow(0, geo.x(), geo.y(), geo.width(), geo.height()).save("test.png");
        }
        
        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #6

          how to get qApp pointer If I am accessing Mainwindow poiter some other QWidget

          1 Reply Last reply
          0
          • Venkatesh VV Offline
            Venkatesh VV Offline
            Venkatesh V
            wrote on last edited by
            #7

            Hi @Qt-Enthusiast
            include bellow line to your mainWindow class then you will get qApp pointer.
            #include<QApplication>

            1 Reply Last reply
            1
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on last edited by
              #8

              I am getting following error

              gui/qt4/qmain/GQMainWindow.cc: In member function ?void GQMainWindow::copy()?:
              gui/qt4/qmain/GQMainWindow.cc:959:10: error: ?class QApplication? has no member named ?primaryScreen?
              qApp->primaryScreen()->grabWindow(0,geo.x(),geo.y(),geo.width(),geo.height()).save("test.png");
              ^

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                Qt Enthusiast
                wrote on last edited by
                #9

                it is qt.4.3.3

                D 1 Reply Last reply
                0
                • Venkatesh VV Offline
                  Venkatesh VV Offline
                  Venkatesh V
                  wrote on last edited by
                  #10

                  Hi,

                  For me it works fine.
                  Try with including both headers,
                  #include <QApplication>
                  #include <QScreen>

                  1 Reply Last reply
                  3
                  • Q Qt Enthusiast

                    it is qt.4.3.3

                    D Offline
                    D Offline
                    Devopia53
                    wrote on last edited by Devopia53
                    #11

                    @Qt-Enthusiast

                    Unfortunately, the QScreen is not supported in Qt 4.3.3.
                    However, you can use QPixmap instead of QScreen. But I can't guarantee it. I'm not currently using Qt 4.3.3.

                    The qApp is equivalent to the pointer returned by the QCoreApplication::instance() or the QApplication::instance() function.

                    1 Reply Last reply
                    2
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #12

                      Why not simply use Windows Key and PrtScr - does it have to be coded?

                      1 Reply Last reply
                      0

                      • Login

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