Unsolved Will the items pointer changed after QList::RemoveAt(i)?
-
How QList store data in memory? Like list or array?
Thank you! -
Hi
http://doc.qt.io/qt-5/qlist.html#details"Internally, QList<T> is represented as an array of T "
so array.
-
@mrjj That's only part of the truth :-)
"Internally, QList<T> is represented as an array of T if sizeof(T) <= sizeof(void*) and T has been declared to be either a Q_MOVABLE_TYPE or a Q_PRIMITIVE_TYPE using Q_DECLARE_TYPEINFO. Otherwise, QList<T> is represented as an array of T* and the items are allocated on the heap." -
@jsulm so if sizeof(T) > sizeof(void*), remove an item does not influence the other item's pointer address in memory...
-
@jsulm thank you very much
-
@jsulm
Thank you.
Last part also important :)
So if not Q_MOVABLE_TYPE etc, its a list.So the short answer is , depends on T , i guess.
-
Hi,
I'd recommend reading this excellent blog about Qt's containers.
-
Looks interesting. I'll read it when I have the time, although I already know Qt's containers have a somewhat poorer performance on average. However I just couldn't bring myself to like the C-style underscore API of STL. And I couldn't help myself but think that the whole "move semantics" nonsense in C++11 was invented only to mitigate the STL's containers' deep copy inefficiencies. Still, the points raised in the article are valid.