[Qt5-feedback] The #include directives for Qt Essentials and Qt Add-on modules

Craig.Scott at csiro.au Craig.Scott at csiro.au
Sun Jul 3 01:22:30 CEST 2011


On 01/07/2011, at 10:30 PM, <lars.knoll at nokia.com<mailto:lars.knoll at nokia.com>> <lars.knoll at nokia.com<mailto:lars.knoll at nokia.com>> wrote:


In there, it should IMO look something like:

QtCore/Qcore
QtCore/qlist.h
...
QtGui/QtGui
QtGui/Qpainter
...
QtAddons/MyAddon/MyAddon
QtAddons/MyAddon/myheader.h
QtAddons/AnotherAddon/...


I agree with the intent, but I do question the naming convention used for the header that pulls in all headers for a module. Duplicating the module name as the "include everything" header seems somewhat confusing. How about a more explicit convention where we append "All" to the name (or some other equivalent)? So the above would become (with corrections for what I think were typos in your QtCore and QPainter examples):

QtCore/QtCoreAll
QtCore/qlist.h
...
QtGui/QtGuiAll
QtGui/QPainter
...
QtAddons/MyAddon/MyAddonAll
QtAddons/MyAddon/myheader.h
QtAddons/AnotherAddon/...


I think the "QtCoreAll" convention would be much clearer to devs what is being included. Having QtCore/QtCore just looks odd to me.

Also, I'm not sure what the intention is with the individual headers, but I thought Qt had moved away from the "qlist.h" form and was instead going with the "Qlist" form? Just wondering if the current thinking for Qt5 is to move back to the former? It's a bit unclear from your examples.



On 7/1/11 1:20 PM, "Haverinen Henry (Nokia-MP-Qt/Tampere)"
<henry.haverinen at nokia.com<mailto:henry.haverinen at nokia.com>> wrote:

Here's an update based on an IRC discussion:

On 7/1/11 1:51 PM, "ext henry.haverinen at nokia.com<mailto:henry.haverinen at nokia.com>"
<henry.haverinen at nokia.com<mailto:henry.haverinen at nokia.com>> wrote:

//Include all classes of a library in Qt Esssentials or of an add-on that
was a Qt4 library

#include <QtFoo>

This needs to be supported for source compatibility, but the correct way
that should be
promoted in the documentation is:

#include <QtFoo/QtFoo>


//include a class from Qt Essentials or from an add-on that was a Qt4 lib

#include <QSomeClass>

The correct way would be
#include <QtFoo/QSomeClass>

I updated these to the naming wiki. The add-on section is still TBD:


//Include all classes from Qt Add-on Foo
//For consistency, this should work for former Qt4 libraries too
#include <QtAddOn/Foo/Foo>

//Include a class from Qt Add-on Foo
#include <QtAddOn/Foo/QSomeClass //class name doesn't have to have the Q
Prefix



--
Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia





More information about the Qt5-feedback mailing list