Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Custom Index Array
Qt 6.11 is out! See what's new in the release blog

Custom Index Array

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    Helson
    wrote on last edited by Helson
    #1

    Hello,
    I have a QVector of QString like:

    data[0][0] = "Person 1";
    data[0][1] = "Person 2";
    

    But I need change the index number to a custom value to associate with an ID.

    data[0][123] = "Person 1";
    data[0][124] = "Person 2";
    

    Is there any way to do this?

    My bests regards!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      you could use a map?
      http://www.cplusplus.com/reference/map/map/map/

      1 Reply Last reply
      1
      • H Offline
        H Offline
        Helson
        wrote on last edited by
        #3

        Thanks for open my eyes!

        Have a great day.

        mrjjM 1 Reply Last reply
        0
        • H Helson

          Thanks for open my eyes!

          Have a great day.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Helson
          :)
          Well, one note about maps.
          if you do
          map[1000]="something"
          and its not there , it will be added.
          So that is not always what one expects.
          Its just a note. you might not encounter it :)

          Good day to you too.

          Also note:
          there is qmap (qt version)

          1 Reply Last reply
          0

          • Login

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