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.



How to Configure a Single Qt Project for Different Operating Systems

There are many cases in every cross-platform development framework that you want your source code to be built differently under different operating systems. For example you might want a method to to use platform specific functions in Windows, Linux and Mac OS X but you don’t want to have different projects for each one of them. If you are in a similar situation then you can use the following approach to have a single integrated project for all operating systems that you are developing for.

Continue reading “How to Configure a Single Qt Project for Different Operating Systems”