Setting application info in a Qt executable file on Windows
Asked Answered
W

2

44

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!

Wheels answered 6/5, 2010 at 21:35 Comment(0)
A
71

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\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

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

Aspa answered 24/7, 2010 at 4:13 Comment(6)
Thanks - thats still maintaining a separate rc file. I ended up doing something where my python build script just wrote an RC file like this.Wheels
this did not work for me nothing changed with all this code added to the resource fileExpugnable
It works great. Make sure you include any paths to your RC file. # Windows RC file RC_FILE = $$PWD/resources/resources.rcLindesnes
Where's the documentation for that syntax you used in resources.rc file?Morceau
@Jack: Documentation is here: msdn.microsoft.com/en-us/library/windows/desktop/…Clamatorial
I did exactly as you said and it didn't change anything (the version is still 0.0.0.0)Lionhearted
C
59

Okay, two years after being asked... but maybe somebody will find it useful...

Try to use the following qmake variables:

VERSION = 0.4.0.1
QMAKE_TARGET_COMPANY = company
QMAKE_TARGET_PRODUCT = product
QMAKE_TARGET_DESCRIPTION = description
QMAKE_TARGET_COPYRIGHT = copyright

More info here.

Corcyra answered 15/8, 2012 at 14:30 Comment(3)
Thanks, haven't tested it because I work in VS, but more answers are always goodWheels
Is there any way to get VERSION at runtime with some piece of code?Obsequious
See APP_VERSION macro here: openguru.com/2009/11/…Smokedry

© 2022 - 2024 — McMap. All rights reserved.