How to Get Current App Version in Qt

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.



One Reply to “How to Get Current App Version in Qt”

  1. This didn’t work for me. I added the above and tried to get the version by QApplication::applicationVersion().

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.