[Development] Qt 6: inline namespace Qt

Olivier Goffart olivier at woboq.com
Sat Sep 7 18:55:55 CEST 2019

On 06.09.19 11:26, Mutz, Marc via Development wrote:
> Hi,
> I would like to propose to make the existing Qt namespace inline and move all 
> of Qt's declarations into it.
> == TL;DR: ==
> Qt can already, optionally, be configured into a user-specified namespace 
> (QT_BEGIN_NAMESPACE/QT_END_NAMESPACE, -qtnamespace), and this is one of the 
> build configurations in the CI, so we're reasonably sure it works. The change 
> would be very limited (via existing macros). Only pre-existing declarations of 
> "namespace Qt" would have to be touched. The change is SC, and makes namespaced 
> and non-namespaced builds behave the same.

You forgot about the forward declarations.  This will break the

  class QLineEdit;

forward declarations that everyone have put in their headers.

There are macro such as QT_FORWARD_DECLARE_CLASS that helps with that, but 
nobody is using them outside of Qt itself.

You would have to deprecate the use of forward declaration of Qt types. It can 
be replaced by something like #include <QtGuiFwd> that contains the declaration 
of all types and could be automatically generated by something like syncqt.


Woboq - Qt services and support - https://woboq.com - https://code.woboq.org

More information about the Development mailing list