QApplication::setWindowIcon 适用于 Windows XP,但不适用于 Windows 7 [英] QApplication::setWindowIcon works on Windows XP, but does not work on Windows 7

查看:45
本文介绍了QApplication::setWindowIcon 适用于 Windows XP,但不适用于 Windows 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个简单的 Qt 应用程序中,如下所示:

In a simple Qt application starting like this:

int main(int argc, char* argv[])
{
  QApplication app(argc, argv);
  app.setWindowIcon(QIcon(":/qapp/appicon.ico"));
...

我们在第二行设置图标(这一行和资源中的图标文件是我的测试程序和Qt向导生成的应用程序的唯一区别).此应用程序在 Windows XP 上运行良好,但在 Windows 7 上我们看不到窗口左上角的图标(系统显示默认图标而不是我的 appicon.ico).

we set the icon in the second line (this line and icon file in resources is the only difference between my test program and application generated by Qt wizard). This application works perfect on Windows XP, but on Windows 7 we can't see our icon in top-left corner of the window (system shows default icon instead of my appicon.ico).

开发者电脑配置:

  • Windows XP-SP3,
  • Qt 5.1,
  • MSVS2010-SP1.

更新:

开发者的操作系统是Windows XP,所以我们暂时回答一下.当我们在装有 Windows 7 的计算机上编译此应用程序时,问题消失了(应用程序在 WinXP 和 Win7 上正确显示图标).所以现在我们必须在 Windows 7 上编译这个应用程序的版本.但这看起来不是完美的解决方案.

Operating system of developer is Windows XP, so we have temporary answer. When we compiled this application on computer with Windows 7, the problem disappeared (application shows the icon correctly on WinXP and Win7). So now we have to compile releases of this application on Windows 7. But it does not looks like perfect solution.

您有什么想法,如何更好地解决这个问题?

Do you have any ideas, how to solve this problem better?

推荐答案

类似的问题是 .ico 图标未显示在 Windows 上.解决方法很简单:

Similar question is .ico icons not showing up on Windows. Solution is simple:

  • 在应用程序目录中创建目录imageformats
  • qico.dll复制进去.
  • create directory imageformats in application dir,
  • copy qico.dll in it.

没有这个插件 QIcon 无法读取 .ico 文件.所以问题不在于 Windows 7 和 Windows XP.问题在于不同计算机上的默认路径变量.

Without this plugin QIcon can't read .ico files. So the problem was not in Windows 7 and Windows XP. The problem was in default paths variables on different computers.

这篇关于QApplication::setWindowIcon 适用于 Windows XP,但不适用于 Windows 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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