3

I watched VoidRealm tutorial, and he easily include QtGui and start using it! but i do the same thing and it doesnt work for me! for example my code doesnt know the QWidget until i include QLabel! or all other Gui element...

#include <QApplication>
#include <QtGui>
#include <QtCore>

int main(int argc, char *argv[])
{

    QApplication a(argc, argv);
    QWidget *win = new QWidget;
    win->setWindowTitle("MBS");

    QGridLayout *gLay = new QGridLayout;

    QLabel *label1 = new QLabel("Name: ");

    win->show();

    return a.exec();
}
Jason Roell
  • 6,679
  • 4
  • 21
  • 28
BlackMB
  • 230
  • 6
  • 20
  • in this case, Qt5 get error from me for QLabel too because i dont include QLabel in it – BlackMB Feb 09 '14 at 22:29
  • If you want a good reason, rather than a fix like Predelnik has given, I think that compilation time is much much faster if you only include the parts you actually use instead of the whole toolkit. – Ben Voigt Feb 09 '14 at 22:40
  • The reason is that QtGui is now the common base for QtQuick2 and QtWidgets, which have no interdependency anymore. So QtGui doesn't include anything widget-related anymore. – Frank Osterfeld Feb 10 '14 at 06:50

1 Answers1

12

In Qt5 most of the previously known as QtGui functionality now is being called QtWidgets.

So try to write #include <QtWidgets>.

Predelnik
  • 5,066
  • 2
  • 24
  • 36