如何在基于 Qt 的项目中设置应用程序图标?

How to set application icon in a Qt-based project?(如何在基于 Qt 的项目中设置应用程序图标?)
本文介绍了如何在基于 Qt 的项目中设置应用程序图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

如何为使用 Qt 制作的应用程序设置应用程序图标?有什么简单的方法吗?这是一个基于 qmake 的项目.

How do you set application icon for application made using Qt? Is there some easy way? It's a qmake-based project.

推荐答案

对于 Qt 5,这个过程由 qmake 自动化.只需将以下内容添加到项目文件中:

For Qt 5, this process is automated by qmake. Just add the following to the project file:

win32:RC_ICONS += your_icon.ico

自动资源文件生成还使用以下 qmake 变量的值:VERSION、QMAKE_TARGET_COMPANY、QMAKE_TARGET_DESCRIPTION、QMAKE_TARGET_COPYRIGHT、QMAKE_TARGET_PRODUCT、RC_LANG、RC_CODEPAGE.

The automated resource file generation also uses the values of the following qmake variables: VERSION, QMAKE_TARGET_COMPANY, QMAKE_TARGET_DESCRIPTION, QMAKE_TARGET_COPYRIGHT, QMAKE_TARGET_PRODUCT, RC_LANG, RC_CODEPAGE.

对于Qt 4,您需要手动完成.在 Windows 上,您需要创建一个 .rc 文件并将其添加到您的项目 (.pro) 中.RC 文件应如下所示:

For Qt 4, you need to do it manually. On Windows, you need to create a .rc file and add it to your project (.pro). The RC file should look like this:

IDI_ICON1 ICON DISCARDABLE "path_to_you_icon.ico"

.pro 条目也应该是特定于 win32 的,例如:

The .pro entry should also be win32 specific, e.g.:

win32:RC_FILE += MyApplication.rc

这篇关于如何在基于 Qt 的项目中设置应用程序图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
STL BigInt class implementation(STL BigInt 类实现)
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)