The icon does not load when you start the application from the outside Qt Creator [duplicate]

左心房为你撑大大i 提交于 2019-12-11 18:32:42

问题


I have a *.ico file.

The icon is loaded by the setWindowIcon() function. I added a *.ico file to the resource file. When I launch the application from Qt Creator, the icon is displayed correctly. But when I launch the application from outside Qt Creator, the icon is not displayed. The application successfully starts and works, but the icon is not displayed.

this->setWindowIcon(QIcon(":/icon/MiniAMR.ico")); // OK, icon load (inside Qt)

/* this string in .pro-file */
RESOURCES += \
    res.qrc

Please, help.


回答1:


You most likely need to copy the plugins/imageformats/qico.dll file from the Qt installation you're building with to within your executable's directory. Put it in a subfolder, like so: <your_executable>/imageformats/qico.dll. If testing a debug build, you'll need the d suffix version of the dll (qicod.dll).

When run from QtCreator, it sets up the correct environment variables so that your application knows where to find the Qt plugins. When run outside of QtCreator, your app probably can't find the plugin.



来源:https://stackoverflow.com/questions/55515996/the-icon-does-not-load-when-you-start-the-application-from-the-outside-qt-creato

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!