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. screenshot
Forum Updated to NodeBB v4.3 + New Features

screenshot

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 353 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.
  • 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");

    C 1 Reply Last reply
    0
    • 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");

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @NanLi Do you mean that pixmap.isNull() == true, screen == nullptr, or that the PNG file is the correct size but blank?

      N 1 Reply Last reply
      0
      • C ChrisW67

        @NanLi Do you mean that pixmap.isNull() == true, screen == nullptr, or that the PNG file is the correct size but blank?

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

        @ChrisW67
        Thank you for your reply!
        After detailed debugging, it was found that it was due to
        Screen==nullptr, so why does QGuiApplication:: primaryScreen() return null

        1 Reply Last reply
        0
        • jeremy_kJ Online
          jeremy_kJ Online
          jeremy_k
          wrote on last edited by
          #4

          This is a duplicate of https://forum.qt.io/topic/151920/screenshot/2?_=1699508498491

          Please stick to a single thread.

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

          1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher locked this topic on

          • Login

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