Results 1 to 1 of 1

Thread: [KINDA FIXED] KDE4 QSystemTrayIcon

  1. #1
    Join Date
    Nov 2008
    Qt products

    Default [KINDA FIXED] KDE4 QSystemTrayIcon

    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:
    Qt Code:
    1. trayIcon = new QSystemTrayIcon(this);
    2. trayIcon->setContextMenu(trayIconMenu);
    3. trayIcon->setToolTip(qAppName() + ": The Note Taker");
    4. QIcon trayIconIcon;
    5. QPixmap pm;
    6. pm.load(QString(":icons/22x22/graphics/tray-icon-22.png"));
    7. trayIconIcon.addPixmap(pm, QIcon::Normal, QIcon::Off);
    8. trayIcon->setIcon(trayIconIcon);
    9. trayIcon->show();
    To copy to clipboard, switch view to plain text mode 
    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.
    Qt Code:
    1. trayIcon->setVisible(false);
    2. qApp->processEvents();
    3. trayIcon->setVisible(true);
    To copy to clipboard, switch view to plain text mode 
    Last edited by onamatic; 26th February 2009 at 13:03. Reason: Workaround found

Similar Threads

  1. Replies: 7
    Last Post: 16th February 2009, 21:59
  2. QSystemTrayIcon Redraw Problems
    By December in forum Qt Programming
    Replies: 0
    Last Post: 7th December 2008, 06:12
  3. QSystemTrayIcon as "main window" design issue
    By nooky59 in forum Qt Programming
    Replies: 5
    Last Post: 17th July 2008, 13:15
  4. QSystemTrayIcon on Windows Mobile 5
    By lovelypp in forum Qt Programming
    Replies: 0
    Last Post: 12th July 2008, 15:57
  5. Replies: 1
    Last Post: 4th February 2008, 11:12


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.