Reputation: 79595
When I created a new Mobile application in Qt Creator, I noticed that in the autogenerated code they use #include <QtCore/QCoreApplication>
instead of #include <QCoreApplication>
, even though both should work the same.
Since Qt Creator itself does that, I assume it's the recommended convention. But is there any reason why this is so, can someone explain what is the point to using #include <QtCore/QCoreApplication>
instead of #include <QCoreApplication>
?
Upvotes: 0
Views: 6787
Reputation: 1706
For code generated from forms you can change that in "Designer" tab options: "Use Qt module name in #include-directive".
I noticed one little but sometimes annoying problem when specifying the module. By default qmake add /path/to/qt/sdk/include
to include path. This means that you can for example do
#include <QtGui/QWidget>
even if in your project file you have
QT -= gui
Then the compilation goes fine but the linker will be mad at you, since QtGui4 library won't be selected for linking.
If you did
#include <QWidget>
the compilation would instead fail.
Upvotes: 1
Reputation: 8207
There are multiple reason for using such convention :-
I have two directories in /usr/include/
both of them have QCoreApplication in them.
Upvotes: 2