[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Alejandro Exojo suy at badopi.org
Sun Jul 12 22:55:04 CEST 2015


El Sunday 12 July 2015, Marc Mutz escribió:
> On Sunday 12 July 2015 13:11:54 Smith Martin wrote:
> > And yet you wrote a blog about it instead of submitting the info to us to
> > update the QList documentation. Currently, the QList page says this:
> > 
> > "QList<T>, QLinkedList<T>, and QVector<T> provide similar functionality.
> > Here's an overview: For most purposes, QList is the right class to use.
> > Its index-based API is more convenient than QLinkedList's iterator-based
> > API, and it is usually faster than QVector because of the way it stores
> > its items in memory. It also expands to less code in your executable."
> >
> > If your argument is correct, then all three of those sentences are false,
> > yes?
> 
> Correct.

With respect to "less code in your executable", note that in your blog post 
you said:

> On the positive side, QList is a real memory saver when we talk about the
> amount of code generated. That is because QList is but a thin wrapper
> around an internal class that maintains the memory for void*s. This leads
> to more compact code, because all the memory management code is shared
> between QLists of different types.

Does this mean that it changed in Qt5, or am I missing something? Because I 
still see QVector being a pure header class, while some part of QList is in 
the cpp file.

-- 
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net



More information about the Development mailing list