View Full Version : System Tray Icon Example with QMainWindow

14th March 2013, 18:39

I'm using the code from the System Tray Icon Example (http://qt-project.org/doc/qt-4.8/desktop-systray.html) in my Qt 5.0.1 application. It works well if I'm using a QDialog which is also used in the example. When I'm trying to use the code to minimize a QMainWindow to the tray the problem occurs. After calling the hide()-method of the QMainWindow when the tray icon is shown the QMainWindow gets hidden (that is the expected behavior of course) but it is still visible in the taskbar.
The still displayed taskbar entry has no more icon and doesn't work correctly anymore. Sometimes that entry doesn't disappear after closing the application (very annoying). It seems to be a bug of Qt or Linux/X11/Gnome. The example has the same problem if a QMainWindow is used instead of a QDialog, so the problem seems to occur independent from my own code (I compiled the example using Qt 5.0.1, too).
The problem only occurs on the Linux plattform (at least on the Gnome desktop). On windows everything works fine.
Does someone know that problem? Is there an workround or an alternative (working) way to minimize a QMainWindow to the tray?