Qt Windows Resource file (. rc file)

Source: Internet
Author: User

Briefly

When using QT under Windows, you typically use Windows resource files-set up information for EXE, including: File description, Product name, product version, copyright, and more ...

Because of the Windows platform-related stuff, the QT Helper has almost no introduction to RC files (briefly mentioned in the setting the Application icon article).

    • Briefly
    • Resource information
      • Effect
      • Realize
    • Icon
      • Parameters
      • Example
    • Versioninfo
      • Formatting versioninfo
      • Parameters

Resource information effects

Realize

First, we add a header file named Version.h that contains the resource information.

#ifndef VERSION_h#define VERSION_h#define PRODUCT_icon"Myapp.ico" //Icon#define FILE_version4,0,2,666   //File version#define FILE_version_str"4.0.2.666"#define PRODUCT_version4,0,2,666   //Product version#define PRODUCT_version_str"4.0.2.666"#define Company_name"Digia"#define INTERNAL_name"Qt Creator.exe"#define FILE_description"QT Creator based on Qt 5.7.0 (MSVC, + bit)"  //Document Description#define LEGAL_copyrightCopyright 2008-2016 the Qt company LTD. All rights reserved. " //Copyright#define ORIGINAL_file_name"Qt Creator.exe"    //Original file name#define PRODUCT_name"Qt Creator"        //Product name#define ORGANIZATION_domain"https://www.qt.io/"  //Domain name#endif//Version_h

Then, add the resource file and set it up ... Example: myapp.rc

#include "winres.h" #include "version.h"//Icons Idi_icon1 icon product_icon//version information Vs_version_info versioninfo Filev Ersion file_version productversion product_version fileflagsmask 0x3fl#ifdef _debug FILEFLAGS 0x1L#else FILEFLAGS 0x0L# endif fileos 0x40004l FILETYPE 0x1l filesubtype 0x0lBEGINBLOCK"Stringfileinfo"    BEGINBLOCK"080404b0"        BEGIN            VALUE "CompanyName", Company_NameVALUE "FileDescription", file_descriptionVALUE "FileVersion", File_version_strVALUE "InternalName", Internal_nameVALUE "Legalcopyright", Legal_copyrightVALUE "OriginalFilename", Original_file_nameVALUE "ProductName", Product_NameVALUE "ProductVersion", Product_version_strEND    ENDBLOCK"Varfileinfo"    BEGIN        VALUE "Translation",0x804, -    ENDEND

Finally, in the. Pro file, add:

RC_FILE += myapp.rc
Icon

Reference Msdn:icon Resource

To define an icon for the specified application:

ICON filename
Parameters
    • NameID
      A unique name or a 16-bit unsigned integer value that identifies the resource.

    • FileName
      The name of the file that contains the resource. The name must be a valid file name, and the full path must be used if the file is not in the current working directory. The path should be a quoted string.

Example

In the following example, two resource icons are defined:

desk1   "desk.ico"11      "custom.ico"

Refer to: Using Icons

Versioninfo

See Msdn:versioninfo Resource and Vs_fixedfileinfo structure

Define a version information resource. This resource contains information about the file's version number, the original file name, and so on. This resource is used in conjunction with version information.

Formatting versioninfo

There are two ways of formatting versioninfo:

fixed-info  block-statement . . . }

Or

versionID VERSIONINFO fixed-infoBEGINblock-statement. . .END
Parameters
    • VersionID
      The version information resource identifier. This value must be 1.

    • Fixed-info
      Version information, such as file version and operating system. This parameter includes the following statements:

Field Description
FileVersion version The binary version number of the file. This version is defined by four 16-bit integers. For example: "FileVersion 3,10,0,61"
ProductVersion version Product version, Ibid.
Fileflagsmask Fileflagsmask Masking of properties
FileFlags FileFlags File properties
Fileos Fileos What operating system is used
FILETYPE FILETYPE File generic type (for DLLs, type Vft_dll)
Filesubtype Subtype File sub-type
    • Block-statement
      Specifies one or more version information blocks. A block contains string information or variable information.

      For more information, please refer to: Stringfileinfo block or Varfileinfo block

The corresponding structure:

typedefstruct tagVS_FIXEDFILEINFO {  DWORD dwSignature;  DWORD dwStrucVersion;  DWORD dwFileVersionMS;  DWORD dwFileVersionLS;  DWORD dwProductVersionMS;  DWORD dwProductVersionLS;  DWORD dwFileFlagsMask;  DWORD dwFileFlags;  DWORD dwFileOS;  DWORD dwFileType;  DWORD dwFileSubtype;  DWORD dwFileDateMS;  DWORD dwFileDateLS;} VS_FIXEDFILEINFO;

Qt Windows Resource file (. rc file)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.