资源文件中的 Qt 图标不显示 [英] Qt icons from resource file do not display

查看:162
本文介绍了资源文件中的 Qt 图标不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Qt Designer qith Qt 5.0.1 制作了一个用户界面,并使用了资源文件中的图标.编译后,可执行文件运行良好,图标按预期显示.但是,当我在另一台计算机上运行该程序时,它们神秘地消失了,我无法恢复它们.

I made a user interface using Qt Designer qith Qt 5.0.1, and I used icons from a resource file. After compiling, the executable runs perfectly fine, and the icons are displayed as expected. However, when I run the programme on a different computer, they mysteriously disappear, and I am not able to get them back.

这可能是什么原因?我认为编译后在可执行文件中硬编码的资源,但这可能是错误的.无论如何,我发现无论我将可执行文件移动到何处,它都会在我自己的计算机上显示图标,而不是在其他计算机上显示图标.

What can be the reason for this? I thought that the resources where hard-coded in the executable after compilation, but that may be wrong. In any case, I find it very peculiar that wherever I move the executable, it displays the icons on my own computer, but not on another one's.

推荐答案

我认为您缺少一些插件.如果您使用的是 Windows 并且您的图标是 .ico 类型的文件,您需要从位于 Qt 文件夹中某处的 imageformats 文件夹中复制 qico.dll 文件(类似于 C:\Qt\Qt5.0.1\5.0.1\mingw47_32\plugins\imageformats) 到一个名为 imageformats 的子目录,您在包含部署的 .exe 文件的目录中创建该子目录.

I think you're missing some plugins. If you're using Windows and your icons are .ico type files, you need to copy the qico.dll file from the imageformats folder located somewhere in your Qt folder (something like C:\Qt\Qt5.0.1\5.0.1\mingw47_32\plugins\imageformats) to a subdir called imageformats that you create inside the directory that contains your deployed .exe file.

这篇关于资源文件中的 Qt 图标不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆