Qt/C++: Icons not showing up when program is run under windows O.S
I am using QT 4.7.0. I have created a project in Windows. I am using some icons on buttons, but when I move the .exe file 开发者_如何学JAVAto another Windows machine the icons don't show. If I run the program in the on the development machine, the icons appear.
I created a qrc file and added the icons to it.
Probably you are having a plugin issue. QT comes with many plugins and your application can not find them on new target.
Check out this this link. Copy the plugins to new target and use qt.conf method to indicate plugin paths.
Your code needs to reference the icons in the resource bundle and not the icons with harddisk paths, e.g.
QIcon icon(":/resources/icon.ico");
and not
QIcon icon("resources/icon.ico");
Profiling a debug version on the target machine with depends.exe will help you show, whether OrcunC or my guess is correct.
I think you need to link the image plugin dlls at run time.
copy necessary dlls in the plugins folder from your Qt directory into your deployment directory and load it.
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString sDir = QCoreApplication::applicationDirPath();
a.addLibraryPath(sDir+"/plugins");
//*********** do your things
return a.exec();
}
Another way to solve a problem is qrs
Please see this page if you can not solve it currently.
Click Setting the Application Icon on Windows.
精彩评论