在Windows上的Qt可执行文件中设置应用程序信息 [英] Setting application info in a Qt executable file on Windows
问题描述
任何人都有从Qt设置应用程序信息的提示(即,右键单击.exe-> properties)吗?
Anyone have an tips on setting the application info (ie. right click on .exe->properties) from Qt?
我可以将任意版本的字符串添加到Qt资源文件(qrc)并显示它们. 但是大多数Windows安装程序都会检查版本号,除了手动维护单独的.RC文件之外,我找不到Qt设置这些字段的方法
I can add arbitrary version strings to Qt resource file (qrc) and display them. But most Windows installers check the version number and I can't find a Qt way of setting these fields other than manually maintaining a separate .RC file
以某种方式可以让您从自动构建中进行更新也很不错!
Some way that lets you update this from an automated build would also be nice!
推荐答案
这是我的操作方法...将一个名为resources.rc的文件添加到您的项目中,内容如下:
Here's how I do it... add a file called resources.rc to your project with the contents:
IDI_ICON1 ICON DISCARDABLE "res/app.ico"
#include <windows.h>
#include "version.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
和一个名为version.h的文件,其内容为:
and a file called version.h with the contents:
#ifndef VERSION_H
#define VERSION_H
#define VER_FILEVERSION 1,0,0,0
#define VER_FILEVERSION_STR "1.0.0.0\0"
#define VER_PRODUCTVERSION 1,0,0,0
#define VER_PRODUCTVERSION_STR "1.0\0"
#define VER_COMPANYNAME_STR "Your Organization"
#define VER_FILEDESCRIPTION_STR "CoolApplication"
#define VER_INTERNALNAME_STR "CoolApplication"
#define VER_LEGALCOPYRIGHT_STR "Copyright © 2010 Your Organization"
#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved"
#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR
#define VER_ORIGINALFILENAME_STR "coolapplication.exe"
#define VER_PRODUCTNAME_STR "CoolApplication"
#define VER_COMPANYDOMAIN_STR "example.org"
#endif // VERSION_H
,最后在您的.pro文件中添加:RC_FILE = resources.rc
.非Windows平台将忽略该值,因此您无需在其前加上win32:
.
and lastly to your .pro file, add: RC_FILE = resources.rc
. Non-Windows platforms will ignore the value so you needn't prefix it with win32:
.
这篇关于在Windows上的Qt可执行文件中设置应用程序信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!