QList<T&> QHash::values or mutable Objects reference list



  • 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?



  • 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.



  • 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!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.