Undeclared identifier QGridLayout
i the header file <QtGui>, but the compiler note me that undeclared identifier QGridLayout
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 ?
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 the
QGridLayout'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.
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 ~