Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
573 views
in Technique[技术] by (71.8m points)

resources - Setting application info in a Qt executable file on Windows

Anyone have an tips on setting the application info (ie. right click on .exe->properties) from 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!

question from:https://stackoverflow.com/questions/2784697/setting-application-info-in-a-qt-executable-file-on-windows

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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"

#define VER_PRODUCTVERSION          1,0,0,0
#define VER_PRODUCTVERSION_STR      "1.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

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:.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...