[Development] QString and related changes for Qt 6

Jaroslaw Kobus Jaroslaw.Kobus at qt.io
Wed May 13 07:57:31 CEST 2020

> From: Development <development-bounces at qt-project.org> on behalf of Thiago Macieira <thiago.macieira at intel.com>
> Sent: Tuesday, May 12, 2020 10:42 PM
> To: development at qt-project.org
> Subject: Re: [Development] QString and related changes for Qt 6

> > On 2020-05-12 11:31, Jaroslaw Kobus wrote:
> > >So, just an idea: instead of repeating the common API part in QString
> > > and QStringView, what about making it one common? E.g. what about:


> > > or (maybe even better):
> > > - aggregating QStringView object as a part of QString API and giving

> QStringView::mid(), for example, returns QStringView, but QString::mid()
> returns QString.
> QString is neither a specialisation nor a broadening of QStringView.

The first option (inheritance) just gives the idea for simple, not perfect solution.

That's why I've mentioned the better option: aggregation: QStringView could be a member
of QString. However, the downside would be that every time you want to call a const method
for QString, you would need to first get access to the QStringView member. The advantage
is that in this way you may easily integrate different interfaces inside one class.

Anyway, if you are saying the APIs of QString and QStringView are not the same, and they
should still differ, than forget about the above.



More information about the Development mailing list