[Development] Qt & Namespaces (was: RE: Some Qt3D feedback)

Sune Vuorela nospam at vuorela.dk
Mon Jun 22 22:51:30 CEST 2015


On 2015-06-18, Koehne Kai <Kai.Koehne at theqtcompany.com> wrote:
>> 1. Each Qt Module "Qt Foo" (name used in docs), with soname
>>    Qt<MajorVersion>Foo, only exports symbols in namespace QtFoo,
>>    potentially with nested inline namespace V<MajorVersion>.
>
> This has the advantage of being a very simple, mechanical rule. But it's also
> very burdensome ... You'll probably end up writing
>
> using namespace QtCore;
>
> in every single source file, since you almost certainly don't want to use 
> QtCore::QString all over the place.

> My 2 cents: Adding namespaces carefully where they make sense is a good thing
> in the long run, and Qt 6 _might_ be a time where we could also touch existing
> modules to avoid clashes. But let's not overdo it. And renaming existing popular classes
> is IMO a non-starter.

If we are doing it, we should definitely add the MajorVersion as in
namespace Qt6Core.

That way, we automatically become immune to crashes from having several
qt verisons in the same process, which is a thing that seems to happen
from time to time for a lot of people by accident. (and quite hard to
debug)

/Sune




More information about the Development mailing list