PDA

View Full Version : Qt usage macro



Momergil
14th July 2013, 18:21
Hello!

I'ld like to know if there is a macro that is defined always when Qt is used in a project/file. I mean, if a #include <QtSomething> is used in a .h or .cpp, is there a macro that it's automatically defined/set to true so one could identify in the code if Qt is being used or not?


To give some context, I'm creating a .h with a set of general defines that I'ld like to use in a standarized form in my applications, some of which may not actually include Qt. Since some of the definitions I'm including in my .h requires Qt to be included, I'ld like to put them inside a macro that will only 'activate' them if Qt is being used:



//.h

#if QT_IS_USED

#define xxxx
#define yyy

#endif



Thanks,

Momergil

ChrisW67
14th July 2013, 21:36
QT_VERSION, or pretty much anything from QtGlobal (http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#macros). However, this sort of environment detection is often done outside the program being built by a configure script that sets flags of your choosing if Qt is present and the user has not disabled it.

Momergil
15th July 2013, 04:22
QT_VERSION, or pretty much anything from QtGlobal (http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#macros). However, this sort of environment detection is often done outside the program being built by a configure script that sets flags of your choosing if Qt is present and the user has not disabled it.

Hmm, I thought about this possibility... It would be, in this case, something like "#if QT_VERSION > 0x000000"?

Now about what you explained regarding using configuration scripts, I'm not sure I understood the proceeding, but still I see no reason about how could I do that given my context (the header file I'm creating).

wysota
15th July 2013, 07:26
It would be, in this case, something like "#if QT_VERSION > 0x000000"?


#ifdef QT_VERSION
is enough unless somebody else (rather than Qt) introduces such define.