Qt 主窗口中未显示图标 [英] Icon is not showing up in Qt Main Window
问题描述
我的 Qt 应用程序包含一个主窗口.我将资源添加到项目中并为资源添加了一个图标.从主窗口源文件中,我使用以下行将图标加载到主窗口.
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"));
当我从 Qt creator 运行应用程序时,它在主窗口中显示了图标但是当我直接从可执行路径运行 exe 时(将所有 Qt 依赖项 dll 复制到该文件夹中)它没有在主窗口中显示图标.
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.
不确定我错过了什么.
推荐答案
将 qico.dll
放在 imageformats
目录中,靠近可执行文件.
Put qico.dll
in the imageformats
directore near executable.
MyAppDir\YourApp.exe
MyAppDir\imageformats\qico.dll
以后,除了png
之外的所有格式都应该有dll.例如 qgif.dll
等.
On future, every format except of png
should have dll. For example qgif.dll
and so on.
这篇关于Qt 主窗口中未显示图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!