.ico 图标未显示在 Windows 上 [英] .ico icons not showing up on Windows

查看:30
本文介绍了.ico 图标未显示在 Windows 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了Qt 资源系统指南和.ico 图标出现在 Linux 上.

当我尝试从 Qt Creator 运行应用程序时,Windows 上没有显示图标.

The icons are not showing up on Windows when I try to run the applicaton from Qt Creator.

怀疑一个基于Qt/C++的插件问题:程序运行时图标不显示Windows 操作系统,但我无法从指南中弄清楚该怎么做 如何创建 Qt 插件.

I suspect a plugin issue based on Qt/C++: Icons not showing up when program is run under windows O.S but I failed to figure out what to do from the guide How to Create Qt Plugins.

是插件问题还是 Windows 上不显示图标?

如果是插件问题:我如何告诉我的应用程序在哪里可以找到 qico.dll?

环境细节:

适用于:Kubuntu 12.04 LTS、Qt Creator 2.4.1 和 Qt 4.7.4(64 位)

Works on: Kubuntu 12.04 LTS, Qt Creator 2.4.1 and Qt 4.7.4 (64 bit)

失败:Windows XP SP2 32 位、Qt Creator 2.4.1 和 Qt 4.7.4(32 位)

Fails on: Windows XP SP2 32 bit, Qt Creator 2.4.1 and Qt 4.7.4 (32 bit)

一切都处于默认状态(开箱即用),我没有弄乱设置.

Everyting is at its default (as installed out of the box), I did not mess with the settings.

resources.qrc

<!DOCTYPE RCC><RCC version="1.0">
    <qresource>
        <file>images/spreadsheet.ico</file>
    </qresource>
</RCC>

也尝试过 <qresource prefix="/">.

来自 applicton.pro

RESOURCES += 
    resources.qrc

OTHER_FILES += 
    images/spreadsheet.ico

在相应的源文件

QIcon(":/images/spreadsheet.ico")

我也尝试了 在 Windows 上部署应用程序

QDir plugins(QCoreApplication::applicationDirPath()+"/plugins");

qDebug() << "Plugin directory" << plugins.absolutePath() << "found?" << plugins.exists();

app.addLibraryPath(plugins.absolutePath());

使用插件目录中的 qico.dll.它应用程序打印插件目录存在但图标仍然不显示.

with the qico.dll in the plugins directory. It application prints that the plugins directory exists but the icons still don't show up.

我再说一遍:它适用于 Linux.

推荐答案

对于未来的 google 访问者:您可以阅读问题下方的评论,因为这是这个答案的诞生地.

For future google visitors: you may read comments under the question, because this is where this answer was born.

所以问题是QIcon默认不支持ico格式,你需要一个插件.在这种情况下,列出 QIcon 支持的格式的 QImageReader::supportedImageFormats() 函数可能会有所帮助.

So the problem is that ico format is not supported by QIcon by default and you need a plugin for this. In such cases QImageReader::supportedImageFormats() function, which lists formats supported by QIcon may be helpful.

如果您的格式不受支持,您可以尝试将 imageformats 文件夹从 Qt 的 plugins 目录复制到您的可执行文件所在的目录中.如果您的应用位于 c:myapp 文件夹中,您应该有 c:myappimageformats 文件夹(不是 c:myapppluginsimageformats>).否则,您必须使用 QCoreApplication::addLibraryPath 设置路径.

In case your format is not supported, you may try to copy imageformats folder from Qt's plugins directory into directory where your executable resides. If your app lies in c:myapp folder you should have c:myappimageformats folder (not c:myapppluginsimageformats). Otherwise you have to set paths using QCoreApplication::addLibraryPath.

还要确保 qico4.dllqicod4.dll(如果您在调试模式下构建)在那里.

Also make sure that qico4.dll and qicod4.dll (if you build in debug mode) are there.

这篇关于.ico 图标未显示在 Windows 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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