[Qt-creator] Getting Qt Creator ready for Qt 5

erik.verbruggen at nokia.com erik.verbruggen at nokia.com
Thu Jan 26 09:02:16 CET 2012


On Jan 25, 2012, at 17:46, ext Daniel Bowen wrote:

> In regards to "- change the coding guidelines to say that Qt headers have to
> be included without module name"
> 
> So
> #include <QString>
> 
> Instead of 
> 
> #include <QtCore/QString>
> ?
> 
> Would that just be for QtCreator's internal reference to Qt headers, or also
> a guideline for everyone's use of Qt headers that is using QtCreator?

Qt Creator internal. That said…:

> If it's a guideline for just QtCreator's internal reference, then I'll defer
> to others.
> 
> If it's a guideline for everyone's use of Qt headers, then I'd be opposed to
> that.  Having the module name in the include lets you just have the parent
> directory in the include path (if you're say referencing Qt out of your own
> source control, or have the same header used both in a QtCreator project and
> a separate build system).  It also works out nicely on Mac for how framework
> headers are referenced if you're using some of Qt as a set of frameworks
> from say an Xcode project.

Very true. But using #include <QtGui/QWidget> will not compile with Qt5. Changing that to <QtWidgets/QWidget> will not compile on Qt4. Fortunately, when qmake generates the makefiles, it supplies the right include paths to the compiler, so using #include <QWidget> works on Linux/Mac/Windows. In XCode you can add some more -I<path-to-qt>/include/<module-name> options to teach where to find headers.

So if you want to compile a Qt-based project with both Qt4 and Qt5, you will probably have to go that route.

-- Erik.


More information about the Qt-creator mailing list