Reputation: 576
I'm having issue with the icons of my Qt Windows application on Windows.
I've set the RC_FILE
with IDI_ICON1 ICON DISCARDABLE
and the icon shows correctly in Windows Explorer.
But I'm still missing the taskbar icon and the Icon that should show up in the start menu.
I already replaced the old 32x32 .ico file that worked for Windoes 7 with one having 256x256, 32x32, 48x48 and 16x16 but this didn't help either.
Any ideas what I'm missing?
Added screenshot for clarity:
Upvotes: 6
Views: 4338
Reputation: 3843
You didn't mark which Qt version you're using, so I'll comment on both qt4 and qt5.
Taskbar Icon
In both versions the Windows taskbar icon is derived from your Dialog/MainWindow/Widget's icon (see https://stackoverflow.com/a/29285256). You can set this for the specific window and its children with QWidget::setWindowIcon().
This should solve your problem, but I'll talk about the Explorer icon, too, for the sake of completeness.
Explorer/Start Menu Icon
Explorer.exe and the Start Menu icons are derived from a *.rc file generated either by you or by qmake. You can set this using your own *.rc file with RC_FILE in Qt4 or Qt5 as described in the comments to your question and I believe you've attempted, but sometimes this will create a conflict with other qmake calls like VERSION
that create a second *.rc file that overrides the first.
Unfortunately, in Qt4 you're out of luck. You must either do all of that work yourself in the *.rc file or give up some features like VERSION.
However, Qt5 added a new option RC_ICON that plays nicely with the other RC-related qmake variables. As long as you're okay with qmake generating the *.rc file, that should do the trick.
The application icon set here should cascade to the window icon in the taskbar and title bar, but in my experience it doesn't seem to happen and it makes more sense to set them separately. The resolutions are different anyway so it's nice to have finer control.
See this link for official Qt5 documentation: http://doc.qt.io/qt-5/appicon.html
Upvotes: 2