[Interest] Inquiry Regarding the Implementation Method of QT COW Containers
Thiago Macieira
thiago.macieira at intel.com
Tue Nov 11 16:17:21 CET 2025
On Tuesday, 11 November 2025 03:54:23 Pacific Standard Time xiaochaoyang0214
wrote:
> Hello,
>
> I'm sorry for the disruption, yet I've encountered a query while delving
> into the Qt container source code. Specifically, I'm curious as to why Qt 6
> employs std::map for QMap, but opts not to use std::vector for QList and
> QVector.
We've had our implementation of arrays since 2001, with Qt 3.0's QValueList,
rewritten in Qt 4.0 as QList and QVector (still distinct types). Using our own
backend allows us to implement COW more simply and also allows us to transform
a QString into a QByteArray (or vice-versa, but usually memory constraints
don't allow that to happen).
We had our own map implementation from that time too. However, by 6.0, it was
felt that our implementation was deficient. Instead of rewriting it like we did
for QHash, we decided it wasn't worth our time and simply wrapped std::map.
> Given that the Qt team has chosen std::map as the foundational
> implementation for QMap, I wonder why an analogous approach wasn't taken
> for QList and QVector. Why not simply rework them as straightforward
> wrapper layers atop std::vector, in a manner similar to how std::map serves
> as the basis for QMap?
Historical context: the question you need to ask is why we've rewritten QMap
and not the other classes.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCG - Platform & Sys. Eng.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5150 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20251111/e058eacf/attachment.bin>
More information about the Interest
mailing list