Need for setWIndowIcon()/setIcon()
-
wrote 18 days ago last edited by
If a Windows application has a .rc file that specifies a .ico file, or a macOS bundle contains a .icns file, do I need to call QWidget::setWindowIcon() or QWindow::setIcon()?
Or perhaps better put under what circumstances do I need/not need to use these?
Thanks
David -
If a Windows application has a .rc file that specifies a .ico file, or a macOS bundle contains a .icns file, do I need to call QWidget::setWindowIcon() or QWindow::setIcon()?
Or perhaps better put under what circumstances do I need/not need to use these?
Thanks
Davidwrote 17 days ago last edited by@Perdrix Docs on QWidget::setWindowIcon:
This property only makes sense for windows. If no icon has been set, windowIcon() returns the application icon
So you need to set if you want a diverging icon (e.g. for applications with multiple windows)
-
If you have a resource icon set up properly it will be used by default for all your windows. Usually you don't need to call these functions. You only call them when you want to change the icon at runtime, e.g. have different icon for one of the windows, like @Asperamanca said, or change the icon to indicate some state change in your app (logged in, connected to something etc.). There's usually a more idiomatic way to do the latter on most OSes though, so it's sometimes a bit of an abuse. Generally if you don't have an immediate idea how you could use that runtime change in a meaningful way don't use it.
-
wrote 17 days ago last edited by Perdrix 5 Jul 2025, 08:42
So, if I read that correctly, then I would normally only call QWindow::setIcon() on Linux?
Is that right?
-
wrote 15 days ago last edited by
I haven't done it, but it seems possible to set application icons on Linux, too....if you know the desktop environment beforehand.
For full reference, please see https://doc.qt.io/qt-6/appicon.html
1/5