On Thu, Apr 26, 2012 at 10:51 PM, Andre Somers <an...@familiesomers.nl> wrote:
> The copy is made at the moment you _append_ the list, not at the moment
> you're modifying it.

actually, it's made at both points. operator[] (the non-const version)
detaches (which causes a copy, if the container's data is shared).
append also does this, as does anything else that modifies the
container. that's why it's best to use at() if you don't explicitly
need to modify the list.

otherwise:

QList<int> listone;
listone << 5 << 6 << 7;
QList<int> listtwo = listone;
listtwo[0] = 10; // if this didn't detach before writing 10, listone
would be modified, and you most certainly don't expect/want that
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to