6

Does Qt maintain any sort of versioning information about your program like .NET does? Like the build number? Or does it provide an easy way to access the SVN revision?

asked Sep 3, 2009 at 20:28

1 Answer 1

11

No.

But if you're using qmake then you can set compiler flags in the build system based on the results of arbitrary commands, which might be usable to do what you want.

For example, if you were using git, you could do something like this in your .pro file:

REVISION = $$system(git rev-parse HEAD)
DEFINES += APP_REVISION=$$REVISION

That would give you an APP_REVISION macro when compiling your program, which you could use like this:

// stringize macro
#define _STR(X) #X
#define STR(X) _STR(X)
QTextStream(cout) << "MyApp revision " STR(APP_REVISION) << endl;
answered Sep 3, 2009 at 22:11
Sign up to request clarification or add additional context in comments.

3 Comments

Neat! I'll have to play around with this. I'm using NetBeans as my IDE and it builds the .pro file itself, so I have to figure out how to get it to not overwrite my changes.
If you do DEFINES += APP_REVISION=\\\"$$REVISION\\\" in your project file, then you don't need to pollute your source files with the STR macro.
@Dan: this is true, however the problem is that the number of backslashes required in your example is platform-specific (even shell-specific, as mingw32-make.exe on windows may run commands via cmd or via sh depending on environment). I think it's quite hard to get it right.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.