问题描述
如何为使用 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 的项目中设置应用程序图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!