Icons disappear on an other computer

2019-07-04 20:53发布

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

1条回答
2楼-- · 2019-07-04 21:24

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

查看更多
登录 后发表回答