Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set my application version for Windows in Qt?

Tags:

c++

qt

qt4

When my application crashes, the Windows Event Viewer always reports my application version as "0.0.0.0". Windows Event Viewer version I can't figure how to set the application version in a way that the Windows Event Viewer recognizes. Changing it with QApplication::setApplicationVersion() doesn't seem to do it.

Obviously there are better ways to debug a program than the Windows Crash Log, but in lieu of all of that, how would I go about setting this value so that Windows recognizes it? My IDE is Qt Creator.

like image 987
Phlucious Avatar asked Apr 06 '17 17:04

Phlucious


3 Answers

You can set the VERSION qmake variable in your pro file:

VERSION = 1.0.0.0

On Windows, triggers auto-generation of an .rc file if the RC_FILE and RES_FILE variables are not set. The generated .rc file will have the FILEVERSION and PRODUCTVERSION entries filled with major, minor, patch level, and build number.

like image 96
kefir500 Avatar answered Sep 19 '22 10:09

kefir500


Use the QCoreApplication class.

QCoreApplication::setApplicationVersion("1.0");
like image 42
X 47 48 - IR Avatar answered Sep 22 '22 10:09

X 47 48 - IR


If you develop a widget app or qml, maybe you want to show your version in WindowTitle full solution would be: In .pro file add:

VERSION = 1.2.3
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

and in QWdiget or QMainWindow

setWindowTitle("Qt " +qtVersion + " Version"+ APP_VERSION);

or in QML

ApplicationWindow {
    title: "Qt " +qtVersion + " Version"+ APP_VERSION
...

enter image description here

like image 36
Andrew Avatar answered Sep 22 '22 10:09

Andrew