当前位置:网站首页>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
边栏推荐
- puzzle(016.4)多米诺效应
- Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
- Find books ()
- Special research report on the market of lithium battery electrolyte industry in China (2022 Edition)
- Awvs batch operation script
- Niuke bm83 string deformation (case conversion, string inversion, string replacement)
- Tensor 省略号(三个点)切片
- 7-1 positive integer a+b (15 points)
- The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
- 表单文本框的使用(一) 选择文本
猜你喜欢
Paper sharing: generating playful palettes from images
Use of constraintlayout
[opengl] advanced chapter of texture - principle of flowmap
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
表单文本框的使用(一) 选择文本
[ue4] material and shader permutation
Code writing and playing method of tonybot humanoid robot at fixed distance
To improve efficiency or increase costs, how should developers understand pair programming?
Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
零拷贝底层剖析
随机推荐
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion
Use of constraintlayout
tonybot 人形機器人 紅外遙控玩法 0630
论文分享:Generating Playful Palettes from Images
Pyqt interface production (login + jump page)
Table of mathematical constants by q779
远程服务器后台挂起 nohup
Yolov5进阶之九 目标追踪实例1
QT - draw something else
PHP GD image upload bypass
puzzle(016.3)千丝万缕
Zzuli:1044 failure rate
7-9 one way in, two ways out (25 points)
tonybot 人形机器人 查看端口并对应端口 0701
cpu飙升排查方法
2021-10-16 initial programming
Luogu p5536 [xr-3] core city solution
Write a 2-minute countdown.
Luogu p5194 [usaco05dec]scales s solution