问题
My Qt application contains a Main Window. I added resource into project and added an icon to the resource. From the main window source file I used the following line to load the icon to the main window.
this->setWindowIcon(QIcon("://img/Icon.ico"));
When I run the application from Qt creator, it shows the icon in the mainwindow BUT when I run the exe from the executable path directly(copied all Qt dependency dlls into that folder) it is not showing the icon in the main window.
Not sure what I am missing.
回答1:
Put qico.dll
in the imageformats
directore near executable.
MyAppDir\YourApp.exe
MyAppDir\imageformats\qico.dll
On future, every format except of png
should have dll. For example qgif.dll
and so on.
来源:https://stackoverflow.com/questions/25679623/icon-is-not-showing-up-in-qt-main-window