Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
809 views
in Technique[技术] by (71.8m points)

c++ - Icons disappear on an other computer

I've created a program with Qt Creator and compiled it with the release mode. I've added all the necessary DLLs and everything runs fine on my computer.

The problem is that when I start the program from an other computer all the icons that I've included are not displayed, whereas everything looks fine on my computer.

Where can this come from?

Edit: The icons are loaded in a qrc file...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Most of Qt's support for file formats relies on plugins. To ensure that your application works as expected when deploying it on non-development machines, you will have to make sure that you have also deployed the relevant plugins. If you haven't, the loading of files (ICO icons in this case) will simply fail silently.

The plugin of importance in this case is qico4.dll (if you're on Windows).

The official Qt documentation contains all the relevant information on Qt deployment for both Windows and Mac. Scroll down to the relevant information on Qt plugins.

As a quick solution you could create a directory named imageformats as a subdirectory of the folder containing your executable, into which you copy the qico4.dll.

(Note: user @smerlin says this has to be plugins/imageformats relative to your executable directory. I seem to recall that my applications did not require the extra plugins directory, but I'll update my answer should I find that this is indeed the case).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...