Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. screenshot

screenshot

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
14 Posts 8 Posters 3.3k Views 3 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.
  • N Offline
    N Offline
    NanLi
    wrote on last edited by
    #1

    When I use the screen>grabWindow function to obtain screen pixel data, the program runs normally on Windows and Ubuntu desktop systems, but on embedded Linux systems, the function returns NULL. My code is as follows:

    QScreen * screen=QGuiApplication:: primaryScreen();

    QPixmap pixmap=screen ->grabWindow (0)// Return null value

    Pixmap. save ("screenshot. png");

    D 1 Reply Last reply
    0
    • B Offline
      B Offline
      Boucher65
      wrote on last edited by Boucher65
      #2

      Consider checking for any missing dependencies or permissions on your embedded Linux system when using QGuiApplication's grabWindow function.

      N 1 Reply Last reply
      0
      • jeremy_kJ Offline
        jeremy_kJ Offline
        jeremy_k
        wrote on last edited by
        #3

        There are several things that can go wrong here.

        • The windowing platform might not allow an application to grab the screen, or might require some configuration external to the running application.
        • The platform integration plugin might not implement QPlatformScreen::grabWindow(), causing the default do-nothing implementation to be used.
        • An underlying driver might not implement the interface used by the platform plugin.

        Make sure the relevant logging category is turned on, and look for output indicating a problem. If that doesn't show anything useful, it may be necessary to read through the platform plugin and verify the steps it takes.

        For relatively easy testing, I would start by attempting to grab a window belonging to the application, and if that works, try a non-root window belonging to another application.

        Asking a question about code? http://eel.is/iso-c++/testcase/

        N 2 Replies Last reply
        0
        • jeremy_kJ jeremy_k

          There are several things that can go wrong here.

          • The windowing platform might not allow an application to grab the screen, or might require some configuration external to the running application.
          • The platform integration plugin might not implement QPlatformScreen::grabWindow(), causing the default do-nothing implementation to be used.
          • An underlying driver might not implement the interface used by the platform plugin.

          Make sure the relevant logging category is turned on, and look for output indicating a problem. If that doesn't show anything useful, it may be necessary to read through the platform plugin and verify the steps it takes.

          For relatively easy testing, I would start by attempting to grab a window belonging to the application, and if that works, try a non-root window belonging to another application.

          N Offline
          N Offline
          NanLi
          wrote on last edited by
          #4

          @jeremy_k Thank you for your reply. Let me describe my device environment information:

          1.The version of Qt is 5.14.2

          1. I use the eglfs platform plugin

          2. The embedded device model I am using is RK3568

          The image I built using the buildroot tool has a Linux kernel version of 4.19.206

          I also have 2 questions to consult with you

          1.What components of Qt do QScreen require to support? (Is it because I am missing the corresponding dynamic library component?)

          1. Do I need driver layer support to use the QScreen class? (Does the driver layer require corresponding famerbuffer read back support?)
          1 Reply Last reply
          0
          • B Boucher65

            Consider checking for any missing dependencies or permissions on your embedded Linux system when using QGuiApplication's grabWindow function.

            N Offline
            N Offline
            NanLi
            wrote on last edited by
            #5

            @Boucher65 Thank you for your reply. Could you please explain in detail what dependencies and permissions I should check.

            1 Reply Last reply
            0
            • jeremy_kJ jeremy_k

              There are several things that can go wrong here.

              • The windowing platform might not allow an application to grab the screen, or might require some configuration external to the running application.
              • The platform integration plugin might not implement QPlatformScreen::grabWindow(), causing the default do-nothing implementation to be used.
              • An underlying driver might not implement the interface used by the platform plugin.

              Make sure the relevant logging category is turned on, and look for output indicating a problem. If that doesn't show anything useful, it may be necessary to read through the platform plugin and verify the steps it takes.

              For relatively easy testing, I would start by attempting to grab a window belonging to the application, and if that works, try a non-root window belonging to another application.

              N Offline
              N Offline
              NanLi
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • jeremy_kJ jeremy_k referenced this topic on
              • N Offline
                N Offline
                NanLi
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  NanLi
                  wrote on last edited by
                  #8

                  I made a mistake and the actual debugging was due to

                  QPixmap pixmap=screen ->grabWindow (0);

                  Pixmap. isNull()==true

                  So why does screen ->grabWindow (0) return null.

                  B 1 Reply Last reply
                  0
                  • N NanLi

                    I made a mistake and the actual debugging was due to

                    QPixmap pixmap=screen ->grabWindow (0);

                    Pixmap. isNull()==true

                    So why does screen ->grabWindow (0) return null.

                    B Offline
                    B Offline
                    Bustoges
                    wrote on last edited by
                    #9

                    @NanLi geometry dash world said in screenshot
                    :

                    I made a mistake and the actual debugging was due to

                    QPixmap pixmap=screen ->grabWindow (0);

                    Pixmap. isNull()==true

                    So why does screen ->grabWindow (0) return null.

                    The reason screen->grabWindow(0) returns null is because it is trying to grab the contents of the entire screen, but the screen is not currently visible. This could be because the screen is not being displayed, or because it is being obscured by another window.

                    To fix this problem, you need to make sure that the screen is visible before you call grabWindow(). You can do this by calling show() on the screen object.

                    QScreen *screen = QGuiApplication::primaryScreen();
                    screen->show();
                    QPixmap pixmap = screen->grabWindow(0);
                    if (pixmap.isNull()) {
                      // Handle the error
                    }
                    

                    This code will first show the screen, and then it will grab the contents of the screen and store them in the pixmap variable. If the pixmap variable is null, then there was an error grabbing the screen contents.

                    jeremy_kJ 1 Reply Last reply
                    0
                    • B Bustoges

                      @NanLi geometry dash world said in screenshot
                      :

                      I made a mistake and the actual debugging was due to

                      QPixmap pixmap=screen ->grabWindow (0);

                      Pixmap. isNull()==true

                      So why does screen ->grabWindow (0) return null.

                      The reason screen->grabWindow(0) returns null is because it is trying to grab the contents of the entire screen, but the screen is not currently visible. This could be because the screen is not being displayed, or because it is being obscured by another window.

                      To fix this problem, you need to make sure that the screen is visible before you call grabWindow(). You can do this by calling show() on the screen object.

                      QScreen *screen = QGuiApplication::primaryScreen();
                      screen->show();
                      QPixmap pixmap = screen->grabWindow(0);
                      if (pixmap.isNull()) {
                        // Handle the error
                      }
                      

                      This code will first show the screen, and then it will grab the contents of the screen and store them in the pixmap variable. If the pixmap variable is null, then there was an error grabbing the screen contents.

                      jeremy_kJ Offline
                      jeremy_kJ Offline
                      jeremy_k
                      wrote on last edited by
                      #10

                      @Bustoges said in screenshot:

                      QScreen *screen = QGuiApplication::primaryScreen();
                      screen->show();
                      

                      There is no QScreen::show() in Qt 5 or 6.

                      Asking a question about code? http://eel.is/iso-c++/testcase/

                      1 Reply Last reply
                      1
                      • N NanLi

                        When I use the screen>grabWindow function to obtain screen pixel data, the program runs normally on Windows and Ubuntu desktop systems, but on embedded Linux systems, the function returns NULL. My code is as follows:

                        QScreen * screen=QGuiApplication:: primaryScreen();

                        QPixmap pixmap=screen ->grabWindow (0)// Return null value

                        Pixmap. save ("screenshot. png");

                        D Offline
                        D Offline
                        Dure1966
                        wrote on last edited by
                        #11
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • W Offline
                          W Offline
                          wyattjohn
                          wrote on last edited by
                          #12

                          Check your embedded Linux system for missing permissions or dependencies before utilizing the grabWindow function of QGuiApplication.

                          1 Reply Last reply
                          0
                          • L Offline
                            L Offline
                            lgxiao
                            wrote on last edited by
                            #13

                            Hello, has your problem been resolved? I have also encountered this situation and would like to ask you how to handle it

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              dearlottery
                              Banned
                              wrote on last edited by
                              #14
                              This post is deleted!
                              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