Icon not showing in the window's title
AngeSurTerre last edited by
I started with QT a week ago, I find it very easy to use. However I cannot mangage to display any icon in the main window's title. Note that I don't have any problem for displaying images inside the window.
System: Ubuntu 14.04
QT version: Qt Creator 3.0.1 Based on Qt 5.2.1 (GCC 4.8.2, 64 bit)
I have created a file 'Images.qrc' that contains the reference to my icon 'Images/MyIcon.png'. My .pro file contains the line:
In the constructor of my main window, I have the line:
The application runs perfectly well, except that the icon does not show up.
I suspect path and filename issue. can you check the path in qrc file ? Can you paste the contents of qrc file ?
ambershark last edited by
Typically I have always set my application icon in the QApplication object.
So for instance:
int main(int argc, char *argv)
QApplication app(argc, argv);
If you are setting it in a mainwindow, perhaps that is the problem. I haven't tested if setting it inside a QWidget works at the application level or not.
There are also other things you need to do to set the icon depending on what OS you are targeting. This stuff doesn't affect the window icon in the titlebar however so I would say they are outside the scope of this thread.
Also like Dheerendra says, you may have an issue with your qrc file or the paths to your icon file. Particularly the "://" part seems off to me with the double slash.
bootchk last edited by
Whether an icon appears in an app's main window title bar (or in the menu bar) depends on the platform HIG guidelines. On Ubuntu platform, I don't think any app displays an icon in the title bar. For example, Firefox doesn't (but it does display an icon in the system tray.) I think an icon in the main window is only for Windows platform. So I think it is working as designed (I also tried in my app, and never saw an icon in Ubuntu.)
Icons that the desktop displays to represent the executable (in the file manager and in the launcher) (and also the icons for the files that an app creates) is another matter altogether. (That is what Ambershark refers to.) People use the word 'app icon' very loosely. The icons for use by the desktop result from packaging, not from calling setWindowIcon(). Packaging is outside the scope of Qt.
AngeSurTerre last edited by
[quote author="bootchk" date="1404992948"]On Ubuntu platform, I don't think any app displays an icon in the title bar.[/quote]
You are right, I never paid attention that Ubuntu was not displaying any icon in their windows (maybe it is a setting that can be changed). On the other hand, the icon that I wanted to appear in the window's title actually appears in the system tray.
So I consider this problem as "solved". Thanks!