Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.14.2
-
None
Description
I want to set the icon for my app, so that it appears in the macOS Dock and whatever the comparable UI in Ubuntu is called (the place where the icons of all running apps are shown). So I call QGuiApplication::setWindowIcon(), which achieves this. Unfortunately, this has the side effect of changing the "default window icon" – or one could say that changing the app icon is really the side effect, since changing the default window icon is the primary documented purpose of QGuiApplication::setWindowIcon(). The two concepts – app icon and default window icon – seem rather conflated in the Qt APIs. And maybe that's the fundamental bug here – maybe there should be a new, separate call, QGuiApplication::setApplicationIcon(), that sets the app icon without changing the default window icon, and QGuiApplication::setWindowIcon() should change the default window icon without changing the app icon, separating those two concepts.
In any case, calling QGuiApplication::setWindowIcon() to set my app icon means that now my app icon appears as the document icon in my app's main windows, which is not what I want; I want the standard document icon (the original default window icon) to be used there. So I tried saving off the original default window icon before changing it, and then setting that original default icon on my main windows by calling QWidget::setWindowIcon(). Unfortunately, this doesn't work; the app icon is still used as the window icon on all my main windows. This appears to be because the original default window icon is not actually a "document" icon, but merely a null icon, and so setting that null icon with QWidget::setWindowIcon() doesn't actually do anything – the window sees that it is a null icon, and continues to fall back on the app icon as the default. So that is what I'm writing this bug report on: that QGuiApplication::windowIcon() just returns a null icon, rather than returning the actual default window icon that will be used if not replaced.
Maybe a third angle on this is: it would be nice if QIcon supplied a constructor that gave the standard document icon for the platform, so that one could get that icon for one's own use. If you'd like me to log a suggestion for that feature request, let me know; but it is rather incidental to the issue reported here.