5
votes

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:

enter image description here

1
We've added an .ico file and an .rc source to our VS project to set our application icon (similar as described in your question). Our GUI is Qt based as well. If I start our application in VS2013 (for debugging) I see a default app icon in the task bar (what confused me a bit until I got used to it). However, in the release built everything is fine. Is this different on your side?Scheff's Cat
I remember that I once (on Windows 7 or even XP) changed/fixed an app icon after having the application already built and tested. I noticed that the update in Explorers thumbnail view was quite delayed. I assumed that Windows/Explorer had somewhere cached the old icon and a certain time later this annoying effect vanished. (Hence, I didn't dig deeper...)Scheff's Cat
@Scheff: we don't use VS, we crosscompile from Linux using mingw64. I already feared that VS might use some poorly documented 'magic' to make icons work. And as I mentioned, Explorer is fine, it's what goes into the taskbar when the application runs.Hurzelchen
It's years ago that I once made an .rc file manually probably reading a doc from anywhere. Since then, I've made them by copy/paste as it was working. Therefore, I cannot tell why these things are there. However, my .rc files contain two icon entries: IDI_ICON1 ICON DISCARDABLE "myApp.ico" and IDI_APPICON ICON "myApp.ico". I just googled IDI_APPICON but all I could find were a #define IDI_APPICON 101 in some hits. I even don't know where the IDIs come from on my side. WinAPI? There is no such definition in our sources.Scheff's Cat
Btw. there is also a comment in my .rc file that the order of icon definitions is important: // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems.Scheff's Cat

1 Answers

1
votes

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