Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to grab screenshot in wayland?
Forum Updated to NodeBB v4.3 + New Features

How to grab screenshot in wayland?

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
12 Posts 8 Posters 4.7k 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.
  • C Offline
    C Offline
    cyxian
    wrote on last edited by
    #3
    This post is deleted!
    1 Reply Last reply
    0
    • VRoninV VRonin

      http://doc.qt.io/qt-5/qwidget.html#grab

      C Offline
      C Offline
      cyxian
      wrote on last edited by
      #4

      @VRonin
      Thanks for your answer. But It can only grab the pixmap of the widget, I need the entire screen

      RatzzR 1 Reply Last reply
      0
      • C cyxian

        @VRonin
        Thanks for your answer. But It can only grab the pixmap of the widget, I need the entire screen

        RatzzR Offline
        RatzzR Offline
        Ratzz
        wrote on last edited by
        #5

        @cyxian
        Have you tried this example??

        --Alles ist gut.

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xiaoyifang
          wrote on last edited by
          #6

          take screenshot in wayland ,seems always give me a black screen.

          S 1 Reply Last reply
          0
          • X xiaoyifang

            take screenshot in wayland ,seems always give me a black screen.

            S Offline
            S Offline
            SCalvi
            wrote on last edited by
            #7

            @xiaoyifang Hi guys!
            Yes I confirm that taking a screenshot under weston wayland just does not happen, here is the code that I use a connected signal onButtonReleased event:

            QScreen *screen = QGuiApplication::primaryScreen();
            if (const QWindow *window = windowHandle()) {
            qDebug() << "using screen from windowHandle()";
            screen = window->screen();
            }
            if (!screen) {
            qDebug() << "NO screen!!!";
            return;
            }
            auto geom = screen->geometry();
            qDebug() << geom;
            QRect screenGeometry = qApp->primaryScreen()->virtualGeometry();
            QPixmap screenGrab = qApp->primaryScreen()->grabWindow(qApp->desktop()->winId(), screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height());
            if (screenGrab.isNull())
            {
            qDebug() << "Grabbed: screenGrab.isNull() = " << screenGrab.isNull();
            } else
            {
            QString fileName = "myshot.png";
            screenGrab.save(fileName);
            qDebug() << "Saved in " << fileName;
            }

            And this is what I get under wayland:
            onButtonReleased()
            using screen from windowHandle()
            QRect(0,0 1920x1080)
            Grabbed: screenGrab.isNull() = true

            The same code works just fine under X11 (of course).
            Is that a bug? Or a Wayland protocol behavior dur to its supposed safety improvement?
            I have to say that: "QPixmap screenGrab = QPixmap::grabWidget(this)" WORKS!!!! but it takes a screenshot of the actual Gui app single window with button that I used to test the screenshot (I would like to take the whole Desktop...

            Any help welcomed :)

            Thank you,
            Sebastien.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Hi,

              KDE does run on top of Wayland, you might want to check the spectacle implementation to see how they do it.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                KDE does run on top of Wayland, you might want to check the spectacle implementation to see how they do it.

                S Offline
                S Offline
                SCalvi
                wrote on last edited by
                #9

                @SGaist

                Thanks for the suggestion, I've had a look and it uses a DBus request, same principle as weston-screenshooter but thisis a fairly slow process and I'm looking at ding at least 30 screenshot per seconds.

                I've read somewhere Qt used libdrm under the hood to perform the screenshot, that's why I tried it.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  So you are rather on the screen recording that shooting. Something like OBS does ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • tim-hiltT Offline
                    tim-hiltT Offline
                    tim-hilt
                    wrote on last edited by
                    #11

                    @SGaist is there an issue or topic I can follow for the Wayland-implementation of QScreen::grabWindow? How is this generally done in the Qt-community?

                    SGaistS 1 Reply Last reply
                    0
                    • tim-hiltT tim-hilt

                      @SGaist is there an issue or topic I can follow for the Wayland-implementation of QScreen::grabWindow? How is this generally done in the Qt-community?

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      @tim-hilt I would go to the KDE folks. They likely have the most experience with Qt + Wayland.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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