Solved Undeclared identifier QGridLayout
-
i the header file <QtGui>, but the compiler note me that undeclared identifier QGridLayout
#include <QtGui>
QGridLayout *gridlayout = new QGridLayout;I know i include <QGridLayout> file can solve it.
does it mean that if there are many widgets, i must include many header files ? -
@ozzy
You're using Qt5, which means that you either have to do a full include of <QtWidgets> (widgets are in a separate module now) or include theQGridLayout
's header explicitly (which is the better way in my opinion).You also might need to add the widgets module to your .pro file, if not done already, like this:
QT += widgets
.Kind regards.
-
@ozzy
to add to @kshegunov post:
In case you are unsure in which module the class is contained you can quickly check on the very top of the related doc page. -
my.pro file contain the sentence: greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
i change #include <QtGui> to #include <QtWidgets> everything works well.
Thank you ~