[Qt-interest] application version and DRY principle

Felix Gorny Felix.Gorny at bitplane.com
Fri Feb 18 15:51:36 CET 2011


hi,

>  How to define application version once and use it everywhere:
>  a) in *.pro file to set custom package name like Program-<version>
VERSION variable in the .pro file where you define the target.

>  b) in c++ sources to pass it to QApplication::setVersionNumber and
>  have about dialog with version number
>
in .pro file:
DEFINES += \
         APPNAME_VERSION_MAJOR=$${APPNAME_MAJORVERSION} \
         APPNAME_VERSION_MINOR=$${APPNAME_MINORVERSION} \
         APPNAME_VERSION_PATCH=$${APPNAME_PATCHVERSION}


in c++-source accessible through the "APPNAME_VERSION_MAJOR"
preprocessor define.

cheers,
felix





More information about the Qt-interest-old mailing list