Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. QList<T&> QHash::values or mutable Objects reference list
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Brainstorm
3 Posts 2 Posters 3.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    ulesQt
    wrote on 27 Jun 2012, 20:16 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 28 Jun 2012, 08:15 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • U Offline
        U Offline
        ulesQt
        wrote on 28 Jun 2012, 13:36 last edited by
        #3

        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 Reply Last reply
        0

        1/3

        27 Jun 2012, 20:16

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved