[Interest] move methods in QList

Christian Gagneraud chgans at gmail.com
Tue Oct 10 23:31:05 CEST 2017


On 10 October 2017 at 19:45, Hamish Moffatt <hamish at risingsoftware.com> wrote:
> I'm interested in storing a big structure in QList, and I would like to move
> it to the list, but unlike std::list QList does not seem to have
> push_back(T&&), insert(..., T&&) etc.
>
> Should I use std::list instead? Or use a QList of pointers (eg
> QSharedPointer) to my structure? Or construct a default item and move my new
> one over it, as in
>
> Big itemToAppend;
> QList<Big> list;
> list.append(Big());
> list.last() = std::move(itemToAppend);
>
> Are there any plans to add the move methods to QList etc?

You might want to read these CppCon17 slides, "Effective Qt: 2017
edition" by Giuseppe D'Angelo (KDAB)
https://github.com/CppCon/CppCon2017/blob/master/Presentations/Effective%20Qt%20-%202017%20Edition/Effective%20Qt%20-%202017%20Edition%20-%20Giuseppe%20D'Angelo%20-%20CppCon%202017.pdf

It's full of interesting information, like:
- Don't use Qt container, unless you have to
- Do not use QList, prefer QVector.

Chris



More information about the Interest mailing list