[Qt-interest] application version and DRY principle

Konrad Rosenbaum konrad at silmor.de
Fri Feb 18 12:50:13 CET 2011


On Fri, February 18, 2011 12:20, Dmitry Teslenko wrote:
> How to define application version once and use it everywhere:
> a) in *.pro file to set custom package name like Program-<version>

Have a look at the DEFINES variable of qmake (there is quite an extensive
reference for qmake in the Qt docu).

> b) in c++ sources to pass it to QApplication::setVersionNumber and
> have about dialog with version number

DEFINES get passed to the compiler, so you can put any kind of macro
inside, for example

DEFINES += MYAPPVERSION="1.2.3 beta build 234"

You probably meant QCoreApplication::setApplicationVersion(QString) - right?



    Konrad




More information about the Qt-interest-old mailing list