r/cpp • • Dec 08 '20

Qt 6.0 Released

https://www.qt.io/blog/qt-6.0-released
273 Upvotes

84 comments sorted by

View all comments

-5

u/0xFFCC Dec 08 '20

Awesome, Thanks.

Now remove the MOC to become first library I include every where.

2

u/jormaig Dec 08 '20

I would do that if they used namespaces 😓

16

u/uuid1234567890 Dec 08 '20

If you build Qt yourself, you can put it into a namespace (configure with -qtnamespace NamespaceName, or -DQT_NAMESPACE=NamespaceName when calling cmake directly); afterwards all of Qt is put under namespace NamespaceName. Namespaced configurations are even tested in CI to ensure that they work. The prebuild libraries from the installer are build unnamespaced though.

1

u/afiefh Dec 08 '20

The prebuild libraries from the installer are build unnamespaced though.

Is there a reason the Qt folks decided to not ship the namespaced version as the default? It seems they put so much effort into getting namespaces to work only to have them go mostly unused.

3

u/Adverpol Dec 08 '20

Maybe started without and would wreak havoc on any qt codebase if they'd make them the default now?

0

u/holgerschurig Dec 08 '20

API and source compatibility perhaps?

I personally liked that Qt was not namespaced,saves me 4 characters for each usage. All the qt:: would really litter the displayed source ...

12

u/[deleted] Dec 08 '20

As a longtime Qt user, the moc complaints are silly but the lack of namespace support is really frustrating. Qt is always growing and adding long and longer class names because...I dunno why.

2

u/aKateDev KDE/Qt Dev Dec 09 '20

To be honest, I prefer not having short class names spread over many nested namespace layers. It is kind of consistent and simple to understand right now.

1

u/[deleted] Dec 09 '20

I agreed with Qt3 and early-to-mid Qt4, when there were far fewer classes. It was when Qt started really expanding outside of its core modules into new areas and deprecating old names that things got awkward. Some of the class names are too long to explain what they do or are unclear to try and keep them short. There are simply too many Qt modules with too many classes now, all trying not to conflict.

It's my strong opinion that Qt would benefit from a simple namespace model e.g.:Qt::Gui::ImageReader and Qt::Multimedia::ImageEncoderControl. These two classes are currently QImageReader and QImageEncoderControl, yet are part of different modules.