Important: Please read the Qt Code of Conduct -

QSystemTrayIcon broken in 4.8.0 under Linux

  • It seems that QSystemTrayIcon is broken in Qt 4.8.0 running under Ubuntu 11.10. My app uses QSystemTrayIcon to install an icon/menu in the system tray, but the icon no longer gets installed in the tray. The app still works under OS X/Lion. The problem can be easily reproduced by building the Qt example app systray which exhibits the same problem. Thank you in advance for any advice.


  • Ubuntu 11.10 that uses Unity has a "white list" for system tray icons. You have to add your app to white list or change settings to show all icons. Take a look at "here":

  • Thanks for your reply t3chNo.

    I visited the link you mentioned and tried it's solution with my app to no avail. I was not expecting it would work because if I run a version of my program built with Qt 4.7.4, it works just fine. However, if I use the very same source code to built the app with Qt 4.8.0 it does not. I even did a fresh installation of Ubuntu 10.11 and got the same results. I have no choice but to conclude that something is amiss with QSystemTrayIcon in 4.8.0.

  • Before I file a bug report I wonder if someone could try this minimal program to verify the bug. I want to make sure the problem is not with my Ubuntu system. This minimal app runs just fine under MacOSX/Lion but it does not display the tray icon when built under Ubuntu 11.10 using the Unity desktop. In both cases I'm using Qt 4.8.0. In the test app I use the icon file (heart.svg) that comes with the Qt example program System Tray Icon (systray).

    @#include <QtGui>

    int main(int argc, char *argv[])
    QApplication app(argc, argv);
    QLabel win("There should be a new icon in the system tray");

    QSystemTrayIcon trayIcon(QIcon("/<absolute path to file>/heart.svg"));;;
    return app.exec&#40;&#41;;


    Thanks in advance for any help.


  • I cannot see this line:
    app.setQuitOnLastWindowClosed(false); // is a must line in this case
    (this line is before QSystemTrayIcon trayIcon(...);)

  • [quote author="broadpeak" date="1328295152"]I cannot see this line:
    app.setQuitOnLastWindowClosed(false); // is a must line in this case
    (this line is before QSystemTrayIcon trayIcon(...);)[/quote]


    I don't think it is needed in this minimal app since I'm creating a QLabel as top widget. This minimal app is not very functional. It just displays the QLabel as top widget and installs the the tray icon. If you click on the tray icon, nothing happens since there is neither a menu associated with it, nor a connection with any signal. To end the app just close the top widget.

    When writing the minimal app I tried using setQuitOnLastWindowClosed(false) and no top widget. It works too, but it was hard to quit the app. So, for simplicity sake, I decided to go that way.

  • I filed bug report QTBUG-24085. In the meantime I'm folding back to Qt 4.7.3 downloaded from the Ubuntu Software Center. This older version of Qt does not have the bug.

Log in to reply