View Full Version : [KINDA FIXED] KDE4 QSystemTrayIcon

26th February 2009, 11:48
KDE4.2, QT 4.5.0

I have a QT app that runs perfectly under KDE3.5. The problem is with QSystemTrayIcon under KDE4.2; sometimes it draws its icon perfectly and sometimes it doesn't.
This code is in the ctor of my main window:

trayIcon = new QSystemTrayIcon(this);
trayIcon->setToolTip(qAppName() + ": The Note Taker");
QIcon trayIconIcon;
QPixmap pm;
trayIconIcon.addPixmap(pm, QIcon::Normal, QIcon::Off);

Start the app. - Icon appears in the tray as a black square with a few pixels drawn at random. Tray icon menus etc. work perfectly though.
Now do something to get the system tray to redraw (start another tray app. say). The redraw nearly always causes our tray icon to display perfectly.

I have tried creating the trayicon, icon and pixmap on the heap and on the stack.
I have tried loading different icons, with different sizes in different ways.
It is extremely difficult to debug as the behaviour is so erratic and there are no indications of any overt errors; apart from this niggle, the app is very well behaved.
It looks like the problem is with KDE4 rather than Qt? Cannot see any references in bug trackers though.

Ring any bells with anyone?

Update: Showing and hiding the tray icon after the main window has been shown causes the icon to appear correctly every time.