Qt 发布软件(添加版本号)

注:以下资料,来源于网上查找

  1. 创建文件 "version.rc",内容设置如下,文件编码设置为gbk,不然会乱码

    # if defined(UNDER_CE)
    #  include 
    # else
    #  include 
    # endif

    VS_VERSION_INFO VERSIONINFO
                FILEVERSION 1,0,0,1
                PRODUCTVERSION 1,0,0,0
                FILEFLAGSMASK 0x3fL
    #ifdef _DEBUG
        FILEFLAGS VS_FF_DEBUG
    #else
        FILEFLAGS 0x0L
    #endif
        FILEOS VOS__WINDOWS32
        FILETYPE VFT_DLL
        FILESUBTYPE 0x0L
        BEGIN
            BLOCK "StringFileInfo"
            BEGIN
                                BLOCK "080404b0"
                BEGIN
                                        VALUE "CompanyName", "TODO: <公司名>\0"
                                        VALUE "FileDescription", "TODO: <文件说明>\0"
                                        VALUE "FileVersion", "1.0.0.1\0"
                                        VALUE "InternalName", "examples_rpa.exe\0"
                                        VALUE "LegalCopyright", "Copyright (C) 2022"
                                        VALUE "OriginalFilename", "examples_rpa.exe\0"
                                        VALUE "ProductName", "TODO: <产品名>\0"
                                        VALUE "ProductVersion", "1.0.0.0\0"
                END
            END
            BLOCK "VarFileInfo"
            BEGIN
                                VALUE "Translation", 0x0804, 1200
            END
        END
    /* End of Version info */
  1. 编译辅助工具添加 "version.rc"文件

一、cmake
//如下代表添加所有后缀是".rc"的文件
${PROJECT_SOURCE_DIR}/*.rc

file(GLOB_RECURSE SOURCE_FILES
${PROJECT_SOURCE_DIR}/*.c
${PROJECT_SOURCE_DIR}/*.cc
${PROJECT_SOURCE_DIR}/*.cpp
${PROJECT_SOURCE_DIR}/*.h
${PROJECT_SOURCE_DIR}/*.hpp
${PROJECT_SOURCE_DIR}/*.ui
${PROJECT_SOURCE_DIR}/*.qrc
${PROJECT_SOURCE_DIR}/*.rc
)
set(PROJECT_SOURCES
    ${SOURCE_FILES}
)

二、qmake
RC_FILE += ./version.rc

你可能感兴趣的:(qt)