Il 18/01/23 17:10, Kai Köhne ha scritto:
Do not use QT_BEGIN_NAMESPACE ... QT_END_NAMESPACE for exampletypes. This namespace is exclusively for types in the Qt libraries.This is broken. How is one going to correctly forward declare Qt names in a namespaced build of Qt without using those macros?Option 1: Do not forward declare the Qt type, but just include the right Qt header. Option 2: Use QT_BEGIN_NAMESPACE..QT_END_NAMESPACE, but only for Qt types,_not_ for all header content. The rule just says that wrapping all of your headers with QT_BEGIN_NAMESPACE, QT_END_NAMESPACE is a misfeature which shouldn't be cargo-culted.
OK, so, the right way to read that rule is that examples shouldn't themselves be declaring things in Qt's namespace. That makes total sense -- no one is allowed to declare things in Qt's namespace but Qt.
Using the namespace macros themselves is fine in order to cope with namespaced builds, e.g. to forward declare Qt types.
I would then also extend the rule, i.e. examples must not introduce any identifier that Qt reserves for itself:
* no class beginning with capital Q * no function beginning with lower q * no macro beginning with Q * ... unless of course they're customization points, like qHash. My 2 c, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development