Reputation: 936
im developing QT application, and im using few icons
this is my resource.qrc file
<RCC>
<qresource prefix="/new/prefix1">
<file>army-officer-icon.png</file>
<file>uac.png</file>
</qresource>
</RCC>
then i ofcourse include it in my .pro file
RESOURCES += \
resource.qrc
and here is the code which takes care of icons:
//this code is part of the mainwindow.cpp
QSystemTrayIcon *trayIcon;
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setIcon(QIcon(":/new/prefix1/army-officer-icon.png"));
trayIcon->show();
//this code is part of the ui_mainwindow.h (generated by QT)
QLabel *label_5;
label_5 = new QLabel(centralWidget);
label_5->setObjectName(QString::fromUtf8("label_5"));
label_5->setGeometry(QRect(40, 302, 46, 21));
label_5->setPixmap(QPixmap(QString::fromUtf8(":/new/prefix1/uac.png")));
label_5->show();
So, this looks reasonable, right ?
===windows 7, developing station, QT installed
also the result effect is as i expected
i can see both icons :: tray icon & uac shield = awesome
but when i move to the other workstation, somethings strange happens
===windows XP, user work station, QT NOT installed
as u can see, the trayicon still has its own icon, but the "uac shield icon" dissapears... its very disturbing, and i really dont get it since both icons are *.png formats, i browsed a lot, and maybe it has connection with qt image plugins (althought i think that i should care about it only when my icon are *.jpeg, *.gif format), but wasnt able to make this solution works...
so any ideas are welcomed. Thanx in advance.
Upvotes: 2
Views: 2066
Reputation: 936
Okay, ive found the solution just after ive posted this (actually , i was quite close, but i copied something with wrong path :/)
locate C:\QtSDK\Desktop\Qt\4.8.0\mingw\plugins
copy plugins/imageformats to your application folder
open main.cpp and add this line of codes
a.addLibraryPath(QCoreApplication::applicationDirPath ()+"/plugins");
compile, and have a look at your beautiful icons :)
Upvotes: 6