When my application crashes, the Windows Event Viewer always reports my application version as "0.0.0.0". 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.
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.
Use the QCoreApplication
class.
QCoreApplication::setApplicationVersion("1.0");
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
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With