I have tried numerous methods to get an application’s own version number and believe me this is the best way to get it. First of all if we consider the fact that setting a Qt application version is done in PRO file (qmake) using the following simple command:
VERSION = 1.2.3.4
Then getting this same value should be the easiest possible method.
Just add the following line to your PRO file after defining version as seen above and you can use the same version string wherever you like in the code:
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
APP_VERSION will contain the string “1.2.3.4” and can be used in the C++ code.