Question

I built a custom Qt5 for msvc2012 using BlueGo.

I was reading the examples and they show this:

#include <QtGui>

 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
     QWidget window;
     window.resize(320, 240);
     window.show();
     window.setWindowTitle(
         QApplication::translate("toplevel", "Top-level widget"));
     return app.exec();
 }

Problem is, QtGui for me is actually a directory and not a file so it cannot be included. I'm using the include files under /qtbase/include/. Am I doing something wrong?

Was it helpful?

Solution

The QtGui header actually exists and simply includes all headers from the QtGui module. You can find it inside the QtGui directory. The compiler is able to find it because the QtGui directory is specified in the include paths. In other words, it's the same as:

#include <QtGui/QtGui>

It's a terrible practice to include the QtGui header though. You should only include what you actually use, otherwise compilation times will increase for no good reason. However, for quick tests and such, it's quite handy.

OTHER TIPS

I know it is a bit late time now but you can do it like this:

add the gui module and widgets in the pro file :

QT += widgets core  gui

And by replaging the include files,

replace

#include <QtGui/QWidget>
#include <QtGui/QApplication>

with

#include <QWidget>
#include <QApplication>

The compiler should recognize it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top