QList<T&> QHash::values or mutable Objects reference list
-
wrote on 27 Jun 2012, 20:16 last edited by
It would be useful to have a QList<T> QHash::values, that could return references to the objects rather than copies of the objects, something like QList<T&> QHash::values, especially for QMultiHash where I can get sets of objects with the same key; so I could modify the contents of the objects
Any ideas?
Is there already an implementation of this feature? -
wrote on 28 Jun 2012, 08:15 last edited by
There is no such value, and I doubt it can be done. However, why don't just put (smart-) pointers in your QHash container instead? That way, it doesn't matter you get a copy.
-
wrote on 28 Jun 2012, 13:36 last edited by
That's what I wanted to do at first, but minimizing the memory leaks, so I think we'll have to use pointers and been really carefull with that.
Thank you very much!
1/3