PDA

View Full Version : QSystemTrayIcon - how to make one?



slava
9th March 2008, 09:31
I did an application with a system tray icon and that works fine. However instead of the tray icon itself it is just an empy space in the systray.
I have tryied:


QIcon icon ("Envelop.ico");
trayIcon->setIcon(icon);

but that do nothing. The manual uses an example with some icons in *.svg format but I have only .jpg or .ico. Can I use those and if yes, how? Please help.

jpn
9th March 2008, 09:42
ICO is not a supported image format (there's a commercial solution: ICO Image Format (http://trolltech.com/products/qt/addon/solutions/catalog/4/Utilities/qticoimageformat/)). For JPEG you must ensure that the JPEG image format plugin has been built. The safest and easiest way is to use PNG.

slava
9th March 2008, 10:03
Thank you. I have converted my .ico file to .png
and did:

QIcon icon ("Envelop.png");
trayIcon->setIcon(icon);
the Envelop.png is in the same directory as my program but that didn't work, the system tray still shows empty icon :(

jpn
9th March 2008, 10:16
Use QCoreApplication::applicationDirPath() or embed it as resource (http://doc.trolltech.com/4.3/resources.html). You know, the current working directory depends on how the application is launched.

slava
9th March 2008, 11:00
Thank you very much. I did it!