Is there a general Qt #define that can be checked for?
-
I have some code files that I would like to share between different platforms (some of which are not supported by Qt). I want to be able to check if it the file is being compiled in a Qt environment and then use some Qt features. Is there a #define that can be checked for presence of the Qt framework to achieve this?
Hypothetical example:
@
#ifdef QT_FRAMEWORK_AVAILABLE#include <QApplication>
double randomInRange(double min, double max)
{
return min + (max - min) * ((double)qrand() / (RAND_MAX + 1));
}#elseif
double randomInRange(double min, double max)
{
return min + (max - min) * ((double)rand() / (RAND_MAX + 1));
}#endif
@ -
You can use QT_VERSION for example or in the case written above also QT_CORE_LIB might be possible.
-
Thanks for this.
QT_CORE_LIB should probably be sufficient for all the cases I will ever encounter.