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. Why does QIcon always return null?
Qt 6.11 is out! See what's new in the release blog

Why does QIcon always return null?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 592 Views
  • 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.
  • NineswissN Offline
    NineswissN Offline
    Nineswiss
    wrote on last edited by
    #1

    There is a high chance I maybe doing this wrong but I am trying to get the app Icon from an open app via it's id. I know the ID is correct however the icon always returns null.

    QWindow *myWIndow = QWindow::fromWinId(10485774); //Correct ID
    qDebug() << myWIndow->icon();  // QIcon(null)
    
    jsulmJ 1 Reply Last reply
    0
    • NineswissN Nineswiss

      There is a high chance I maybe doing this wrong but I am trying to get the app Icon from an open app via it's id. I know the ID is correct however the icon always returns null.

      QWindow *myWIndow = QWindow::fromWinId(10485774); //Correct ID
      qDebug() << myWIndow->icon();  // QIcon(null)
      
      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Nineswiss On what platform/OS/window manager? What is the Qt version?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • NineswissN Offline
        NineswissN Offline
        Nineswiss
        wrote on last edited by
        #3

        @jsulm Linux/Fedora/Openbox/ qt6.3.0

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          The QWindow* provided by this method is limited. From the docs, "this method creates a QWindow object which can be used to represent the window when invoking methods like setParent() and setTransientParent()." The subsequent note really tries to discourage anything except re-parenting.

          You may need to use X11 API calls to get the _NET_WM_ICON property. Try running
          xprop -id 10485774 _NET_WM_ICON
          from a shell (or leave out the id and click a window) to see a monochrome console rendering of icons there to be had.

          1 Reply Last reply
          3
          • NineswissN Offline
            NineswissN Offline
            Nineswiss
            wrote on last edited by
            #5

            Thanks @ChrisW67 that is actually what I ended up doing. Then saving the output as pngs to a tmp dir.

            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