Get default app icon on Windows
-
Hi! I want to get default application icon from
QFileIconProviderbut there are only:enum QFileIconProvider::IconType
QFileIconProvider::Computer QFileIconProvider::Desktop QFileIconProvider::Trashcan QFileIconProvider::Network QFileIconProvider::Drive QFileIconProvider::Folder QFileIconProvider::FileScreenshot:

I can navigate to some system executable file without icon to get this default icon using
QFileIconProvider, but I think there should be another approach.
How to get this icon? Thanks.Update:
I have found the identifier of default app icon -IDI_APPLICATION. The problem now is how to convert it toQIconorQString? I have triedQString::fromWCharArray(IDI_APPLICATION)andQString::fromStdWString(IDI_APPLICATION)but it doesn't work, the app crashes. How to convert it? Thanks. -
Hi! I want to get default application icon from
QFileIconProviderbut there are only:enum QFileIconProvider::IconType
QFileIconProvider::Computer QFileIconProvider::Desktop QFileIconProvider::Trashcan QFileIconProvider::Network QFileIconProvider::Drive QFileIconProvider::Folder QFileIconProvider::FileScreenshot:

I can navigate to some system executable file without icon to get this default icon using
QFileIconProvider, but I think there should be another approach.
How to get this icon? Thanks.Update:
I have found the identifier of default app icon -IDI_APPLICATION. The problem now is how to convert it toQIconorQString? I have triedQString::fromWCharArray(IDI_APPLICATION)andQString::fromStdWString(IDI_APPLICATION)but it doesn't work, the app crashes. How to convert it? Thanks.Did you see this section already?
The detailed description of QFileIconProvider says:
The QFileIconProvider class provides file icons for the QDirModel and the QFileSystemModel classes.Does not seem to be what you require, if I understand you correctly.
-
Did you see this section already?
The detailed description of QFileIconProvider says:
The QFileIconProvider class provides file icons for the QDirModel and the QFileSystemModel classes.Does not seem to be what you require, if I understand you correctly.
This is not what I'm looking for. I need to apply this default icon for another apps (or for example set this default icon on
QPushButton) usingsetIconfunction. I need a handle to Windows default app icon. -
I have found the identifier of default app icon -
IDI_APPLICATION. The problem now is how to convert it toQIconorQString? I have triedQString::fromWCharArray(IDI_APPLICATION)andQString::fromStdWString(IDI_APPLICATION)but it doesn't work, the app crashes. How to convert it? Thanks. -
Hi, try (assuming you want to show the icon in a QLabel):
ui->label->setPixmap(QtWin::fromHICON(LoadIcon(NULL,IDI_APPLICATION)));Note: you need to add
LIBS += -luser32to your .pro file and #include "QtWinExtras"It works. Thanks.