[Development] Proposal: Deprecate QVector in Qt 6

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Fri Apr 24 22:14:36 CEST 2020

On 4/24/20 9:03 PM, Jason H wrote:
>> In fact, it is-a QList<QString>. What's the problem here with its naming?
> Because I can't QSringList{"me", "you"}.join() with a QList.

I didn't say that it's a typedef for QList<QString>, but is-a -- it 
inherits, precisely to provide that kind of convenience.

> Thinking outsize of the box...
> It seems that all this is cause d by someone wanting to store a pointer to an item in QVector, which may be reallocted and therfore have moved.

All this => what's this?

> It seem then that the only thing to do is to use a traditional QList, or return only some kind of ref which will be a stable reference to the item.
> QStableRef r9 = vector[9];
> vector.resize()
> // r9 is updated during resize() and still points to that it was meant to.
> It's not good practice to store a ref to something that can be realloated. I don't know how you can prevent people from doing that with offering T& operator[](int i);

QList today offers exactly that. In array-of-pointers-mode it also 
offers stability of references.

Giuseppe D'Angelo | giuseppe.dangelo at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200424/f4cee7c7/attachment.bin>

More information about the Development mailing list