[Solved] New Qt Gui project from QtCreator does not compile
-
Thanks for looking into this, I'll rephrase.
It's real easy to reproduce this problem.- Start QtCreator (/opt/Qt5.0.1/Tools/QtCreator/bin/qtcreator)
- File / New File or Project
- Select Applications / Qt Gui Appication and do Choose...
- Choose any name
- I get a list of kits, I choose "Desktop Qt 5.0.1 GCC 64bit" and Debug + Release options
- Then hit Next until I get Finish, accepting defaults
- Now QtCreator has created an empty Qt Gui app
- Build the app with Build All
- Error: QMainWindow: No such file or directory
Kind regards,
Wino. -
Oh, and yes Qt 4.8.1 works fine.
-
Is QMainWindow header included with <QtGui/QMainWindow>, by any chance? If so, it is wrong (in Qt5), and of course a bug. Use just <QMainWindow> or <QtWidgets/QMainWindow> instead.
Can't check myself, I'm not using the prebuild packages, but enjoy building stuff myself with clang :)
-
IMHO the bug is in the fact that qmake does not add an include for QtWidgets in the Makefile if you put QT += widgets in the .pro file.
I know putting <QtWidgets/QMainWindow> will fix the include issue but it should not be neccessary to put <QtWidgets/...> in your source code if you put QT += widgets in your .pro file.
QtCreator does not put <QtWidgets/...> in it's generated source code so the build of an app generated by QtCreator fails.
-
As expected, both Qt 5.0.1 (+QtCreator 2.6.2) build from source or the pre-build binaries have the same issue.
-
Either I misunderstand you, or you misunderstand the nature of qmake.
QT+= widgets adds necessary calls to the Makefile so that libQtWidgets can be included and linked without hassle. You still do need to include the headers in source code. <QMainWindow> should be enough, but maybe something is wrong there.
-
In my application, if I include <QSqlRecord> I just put #include <QSqlRecord> and not #include <QtSql/QSqlRecord>. This works because I put QT += sql in my .pro file.
qmake adds the extra include path for QtSql, it also add the QtSql library for linking, fine.I would expect the same behaviour from qmake if I put QT += widgets in my .pro file.
So that I only need to put #include <QMainWindow> in my source code and not #include <QtWidgets/QMainWindow>.Whoever wrote QtCreator assumes the same as me because (s)he puts #include <QMainWindow> in the generated source code and not #include <QtWidgets/QMainWindow>.
That is why apps generated by QtCreator do not compile on Qt5.0.1.
But I'm repeating myself here. -
Report it on "Jira":https://qt-project.org/wiki/ReportingBugsInQt, then.
-
Thanks. I will.
-
There was an mkspec directory in my home directory.
This messed things up.