I have to make sure my project builds both in Qt 4 (I have 4.7 installed) and Qt 5 (I have 5.5).
For that, in many places I have, in pro file:
NOT_QT_4 {
QT += widgets
} else {
#Nothing specific
}
and in code:
#ifdef NOT_QT_4
#include <QtWidgets>
#else
#include <QtGui>
#endif
Yet every time I switch build from Qt 4 to Qt 5, I get an error:
ui_somefile.h:14: error: QtGui/QAction: No such file or directory
#include <QtGui/QAction>
^
This is in a ui_
file generated from a form created using the Qt Designer... so I can't put the defines that I use in normal code.
It is extremely difficult to get it to build: Build->Clean All
, erase every single file on disk (debug
, release
, make*
, ui_*
), Build->Clean All
again (useless of course), run qmake
, build again ...
still I have to do it repeatedly because the ui_
file seems to regenerate with defective info.
Since I have to make sue every commit builds in both Qt4 and Qt5 versions, I have to do this a lot right now...
How can I make it build correctly in Qt5 - and alternatively how can I clean that particular portion of the build easily ? (a clean build takes several minutes... giant project...)
I recommend that you put those ui_*.h files in a different location, such that the results could be different and compile uniquely between QT versions.
NOT_QT_4 {
UI_HEADERS_DIR = foo
} else {
UI_HEADERS_DIR = bar
}