user597987
user597987

Reputation:

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 to 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.

Upvotes: 3

Views: 8242

Answers (5)

O.C.
O.C.

Reputation: 6819

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.

Upvotes: 7

PeanutStars
PeanutStars

Reputation: 18

Please see this page if you can not solve it currently.

Click Setting the Application Icon on Windows.

Upvotes: 0

Lwin Htoo Ko
Lwin Htoo Ko

Reputation: 2406

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();
}

Upvotes: 1

Jens
Jens

Reputation: 6329

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.

Upvotes: 3

TheHorse
TheHorse

Reputation: 2797

Another way to solve a problem is qrs

Upvotes: 0

Related Questions