当前位置:网站首页>How does vs+qt set the software version copyright, obtain the software version and display the version number?
How does vs+qt set the software version copyright, obtain the software version and display the version number?
2022-07-03 14:49:00 【Jack1009HF】
VS+Qt How to set software version copyright , Get the software version and display the version number ?
Preface
VS edition :VS2019
QT edition :Qt5.12.3(msvc2017_64)
One 、 Effect display
1. Before adding version information VS After adding version information 
2. Before getting version information VS After obtaining version information 
Two 、 edition 、 Copyright information settings
- stay VS in , Right click the item name -> add to -> resources ;

- In the pop-up window , choice Version-> newly build ;

- In the pop-up version explorer, you can set the version number 、 Corporate name 、 Copyright 、 Set the software name and other information ;

- Exit Explorer after saving , Regenerate the executable , Executable file (.exe) The version is displayed 、 Copyright and other information .

3、 ... and 、 Version information acquisition and display
- You need to add version resources to get files VersionUpdate.h;
VersionUpdate.h file
#pragma comment(lib, "version.lib")
#include <QObject>
#include <windows.h>
#include <tchar.h>
class VersionUpdate
{
public:
static QString VersionUpdate::GetVersion()
{
int nMaxPathName = 4096; // Max length of file name/path
TCHAR* pBuffer;
UINT nItemLength;
void* pData, * lpBuffer;
QString sVersion;
DWORD dwInfoSize, dwHandle;
VS_FIXEDFILEINFO* pFileInfo;
// Get the file path and name
pBuffer = new TCHAR[nMaxPathName];
GetModuleFileName(NULL, pBuffer, nMaxPathName - 1);
// Get File Version Info size
dwInfoSize = GetFileVersionInfoSize(pBuffer, &dwHandle);
if (dwInfoSize > 0)
{
pData = new TCHAR[dwInfoSize];
if (GetFileVersionInfo(pBuffer, dwHandle, dwInfoSize, pData))
if (VerQueryValue(pData, _T("\\"), &lpBuffer, &nItemLength))
{
pFileInfo = (VS_FIXEDFILEINFO*)lpBuffer;
sVersion = QString("%1.%2.%3.%4")
.arg(pFileInfo->dwProductVersionMS >> 16)
.arg(pFileInfo->dwProductVersionMS & 0xFFFF)
.arg(pFileInfo->dwProductVersionLS >> 16)
.arg(pFileInfo->dwProductVersionLS & 0xFFFF);
// Calculate the product version as a number, you can delete the next statement if you don't need it.
DWORD dwProductVersion = (pFileInfo->dwProductVersionMS >> 16) * 1000 +
(pFileInfo->dwProductVersionMS & 0xFFFF) * 100 +
(pFileInfo->dwProductVersionLS >> 16) * 10 +
(pFileInfo->dwProductVersionLS & 0xFFFF) * 1;
}
// Delete the data buffer
delete[] pData;
}
// Get rid of the allocated string buffer
delete[] pBuffer;
return sVersion;
}
private:
};
- stay main.cpp Add these sentences to the code ;
#include "ApplicationVersionUpdate.h"
#include <QtWidgets/QApplication>
// Get the version number
#include "VersionUpdate.h"
#define AppTitle (QString)("ApplicationVersionUpdate_V"+VersionUpdate::GetVersion())
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ApplicationVersionUpdate w;
// Set the display content of the status bar
w.setWindowTitle(AppTitle);
w.show();
return a.exec();
}
- Run the project , The window frame status bar displays the configured version information .

Four 、 Engineering source
边栏推荐
- PS tips - draw green earth with a brush
- Several sentences extracted from the book "leather bag"
- [graphics] adaptive shadow map
- [ue4] material and shader permutation
- Déformation de la chaîne bm83 de niuke (conversion de cas, inversion de chaîne, remplacement de chaîne)
- Zzuli:1052 sum of sequence 4
- How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
- CentOS7部署哨兵Redis(带架构图,清晰易懂)
- [qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
- Zzuli: sum of 1051 square roots
猜你喜欢

How to color ordinary landscape photos, PS tutorial

Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue

Paper sharing: generating playful palettes from images

US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars

Protobuf and grpc

Tonybot Humanoïde Robot Infrared Remote play 0630

亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?

Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
![[ue4] HISM large scale vegetation rendering solution](/img/a2/2ff2462207e3c3e8364a092765040c.jpg)
[ue4] HISM large scale vegetation rendering solution

Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
随机推荐
Zzuli:1059 highest score
C language memory function
Analysis of gene family characteristics - chromosome location analysis
Puzzle (016.3) is inextricably linked
US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
Zzuli:1052 sum of sequence 4
ASTC texture compression (adaptive scalable texture compression)
Tonybot humanoid robot infrared remote control play 0630
牛客 BM83 字符串變形(大小寫轉換,字符串反轉,字符串替換)
C language STR function
My QT learning path -- how qdatetimeedit is empty
Optical cat super account password and broadband account password acquisition
基因家族特征分析 - 染色体定位分析
Introduction to opengl4.0 tutorial computing shaders
洛谷P5536 【XR-3】核心城市 题解
Showmebug entered Tencent conference, opening the era of professional technical interview
Zzuli: cumulative sum of 1050 factorials
Protobuf and grpc
Amazon, express, lazada, shopee, eBay, wish, Wal Mart, Alibaba international, meikeduo and other cross-border e-commerce platforms evaluate how Ziyang account can seize traffic by using products in th