Why does QIcon always return null?
-
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)
-
@Nineswiss On what platform/OS/window manager? What is the Qt version?
-
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.