当前位置:网站首页>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
边栏推荐
- Yolov5进阶之九 目标追踪实例1
- Zzuli:1058 solving inequalities
- NOI OPENJUDGE 1.3(06)
- Get permissions dynamically
- Showmebug entered Tencent conference, opening the era of professional technical interview
- QT - draw something else
- Niuke: crossing the river
- Find books ()
- 556. The next larger element III: simple construction simulation questions
- Simulation of LS -al command in C language
猜你喜欢
![洛谷P4047 [JSOI2010]部落划分 题解](/img/7f/3fab3e94abef3da1f5652db35361df.png)
洛谷P4047 [JSOI2010]部落划分 题解

分布式事务(Seata) 四大模式详解

556. The next larger element III

Paper sharing: generating playful palettes from images

Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules

Niuke: crossing the river

On MEM series functions of C language

Rasterization: a practical implementation (2)

Puzzle (016.3) is inextricably linked

Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
随机推荐
【微信小程序】WXSS 模板样式
C language to realize mine sweeping
.NET六大设计原则个人白话理解,有误请大神指正
Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things
adc128s022 ADC verilog设计实现
1017 a divided by B (20 points)
光猫超级账号密码、宽带账号密码 获取
Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
C language DUP function
【7.3】146. LRU缓存机制
Yolov5进阶之八 高低版本格式转换问题
Plane vector addition
C language to implement a password manager (under update)
tonybot 人形機器人 紅外遙控玩法 0630
Mongodb index
PS tips - draw green earth with a brush
Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
Paper sharing: generating playful palettes from images
Tensor 省略号(三个点)切片
Zzuli:1053 sine function