PDA

View Full Version : Constructing tray icon with QIcon



Tiansen
6th October 2009, 08:20
Hello,

I have made tray icon with QSystemTrayIcon.
I use following to set icon of trayicon (I use qrc resources):

trayicon->setIcon(QIcon(":/ikona/sending.gif"));

On my computer icon is constructed ok, but when deployed on another computer, I get empty icon - tray icon with no picture in it. How is this possible - I thought that Qt resources are compiled into binary and because of that always available when deployed to another computer? Any idea, what is wrong here?

AviMittal
6th October 2009, 08:34
try this:

trayIcon = new QSystemTrayIcon(this);
icon.addPixmap(QPixmap(QString::fromUtf8(":/mailbox.png")), QIcon::Normal, QIcon::Off);
trayIcon->setIcon(icon);

for this you need to add the image file name into your qrc file also don't forget to copy the image file while moving to other system.

:)

aamer4yu
6th October 2009, 09:38
It could also be a problem of image plugin.
copy the proper dll from QTDIR\plugins\imageformats to your destination and see if it works

Tiansen
6th October 2009, 09:54
Thanks for suggestions, I converted gif to png, and now it works! Excellent!

aamer4yu
6th October 2009, 12:04
I converted gif to png, and now it works!
Then surely it must be a case of missing image plugin dll. Try my last post and see if it works for gif ?
Also is ur qt built with gif support ?

Tiansen
6th October 2009, 20:04
I am not sure if I've done it right. I copied qgif4.dll into plugins\imageformats subfolder of where my exe is deployed.
It still does not work with gif.
I am using prebuilt Qt binaries that came with 2009.03.

yan
6th October 2009, 23:02
Hi

I am not sure if I've done it right. I copied qgif4.dll into plugins\imageformats subfolder of where my exe is deployed.


you must copy this dll into imageformats subfolder of where your exe is deployed and not plugins\imageformats ;)

Tiansen
7th October 2009, 06:18
Yes and now it works with gif too!!! Thanks!