I have just one question: is a define (or something similar) available if you are compiling some code to know if the GUI flag has been set?
I'll explain better. I have some code I want to reuse for different programs in QT. Now, some parts of this code are used just in GUI applications (or better widget applications) and depend on QtGui and QtWidgets. I'd like to put these parts in a conditional block (#if
or #ifdef
) for them to be compiled only in the projects where the GUI and/or widget libraries are included.
And, before you suggest this, making a library is not a solution. I'd prefer a define...
EDIT:
Probably I didn't explain myself clearly. What I'm looking for is the define associated with the GUI inclusion. Example:
FILE myfile.h
#ifdef THE_QT_GUI_DEFINE_FLAG
#include <QPainter.h>
#endif
PROJECT A: in the QMake file I write:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
PROJECT B: in the QMake file I write:
QT -= gui
Now, I want QPainter.h
to be included just in project A. Do you know what is the define flag set when I add the gui library? I tried with QT_QTGUI_MODULE_H
, but it doesn't work (probably because it is used just when you compile THE qt library).