79377376

Date: 2025-01-22 10:38:26
Score: 0.5
Natty:
Report link

Things have changed (again) with Qt 6

We are now in Qt 6 and things have changed, so the documentation. It gives a clear and different answer (again) to this question:

QList is one of Qt's generic container classes. It stores its items in adjacent memory locations and provides fast index-based access. QVector used to be a different class in Qt 5, but is now a simple alias to QList.

QList and QVarLengthArray provide similar APIs and functionality. They are often interchangeable, but there are performance consequences. Here is an overview of use cases:

QList should be your default first choice.

• QVarLengthArray provides an array that reserves space on the stack, but can dynamically grow onto the heap if required. It's good to use for short lived containers that are usually small.

• If you need a real linked list, which guarantees constant time insertions mid-list and uses iterators to items rather than indexes, use std::list.

Note: QList and QVarLengthArray both guarantee C-compatible array layout.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Jean Yne