Ah I see...  So it's the const-ness of the object itself and not the reference 
that is controlling which operator[] gets used.  That makes sense to me now.

I'm still not sure what is happening with all that memory though.  I'm asking 
for a reference so I don't expect that I own what is returned yet it seems to 
be making a deep copy each time and not freeing that memory since in seconds 
the memory use of the process sky-rockets until the whole system starts 
thrashing and eventually crashes and burns.  Seems odd behaviour to get from a 
couple of lines of code like that.  Would never have expected that to be a 
memory leak!  Makes me wonder if I've done the same kind of mistake in other 
places where it's not so noticeable...

--
Brad


On Jan 09, 2015, at 01:21 PM, Keith Gardner <kreios4...@gmail.com> wrote:

QList can return a const & with the [] operator [1]. The documantation even 
says it's the same as .at().

[1] http://doc.qt.io/qt-5/qlist.html#operator-5b-5d-2

That is true if the QList is const when calling the function.  If it is not, 
the other operator [1] documentation describes the behavior.

[1] http://doc.qt.io/qt-5/qlist.html#operator-5b-5d 
 
_______________________________________________
Interest mailing list
Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to