当前位置:网站首页>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
边栏推荐
- Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
- Zzuli:1041 sum of sequence 2
- Optical cat super account password and broadband account password acquisition
- Joomla! CMS 3.0~3.4.6 RCE
- 556. 下一个更大元素 III : 简单构造模拟题
- [combinatorics] permutation and combination (set combination, one-to-one correspondence model analysis example)
- [ue4] HISM large scale vegetation rendering solution
- [engine development] rendering architecture and advanced graphics programming
- Write a 2-minute countdown.
- Niuke: crossing the river
猜你喜欢

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

远程服务器后台挂起 nohup

Use of constraintlayout

Four data flows and cases of grpc

Pytorch深度学习和目标检测实战笔记

Introduction to opengl4.0 tutorial computing shaders
![[ue4] HISM large scale vegetation rendering solution](/img/a2/2ff2462207e3c3e8364a092765040c.jpg)
[ue4] HISM large scale vegetation rendering solution

How to color ordinary landscape photos, PS tutorial

retrofit

Solve the problem that PR cannot be installed on win10 system. Pr2021 version -premiere Pro 2021 official Chinese version installation tutorial
随机推荐
洛谷P3065 [USACO12DEC]First! G 题解
Find books ()
从书本《皮囊》摘录的几个句子
Zzuli:1059 highest score
Several sentences extracted from the book "leather bag"
Qt development - scrolling digital selector commonly used in embedded system
7-3 rental (20 points)
How to color ordinary landscape photos, PS tutorial
远程服务器后台挂起 nohup
[ue4] cascading shadow CSM
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
Yolov5进阶之九 目标追踪实例1
Zzuli:1045 numerical statistics
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
Common shortcut keys in PCB
Code writing and playing method of tonybot humanoid robot at fixed distance
tonybot 人形機器人 紅外遙控玩法 0630
Zzuli:1047 logarithmic table
分布式事务(Seata) 四大模式详解
牛客 BM83 字符串變形(大小寫轉換,字符串反轉,字符串替換)