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. How to insert hash value from a QStringList using a for loop (solved)

How to insert hash value from a QStringList using a for loop (solved)

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.0k 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
    houmingc
    wrote on last edited by
    #1

    error:
    error: no match for 'operator[]' in StationHash.QHash <k,v)::value
    @
    QStringList StationList
    QHash<int, QString> stationHash;

    QHash<int, QString> ::iterator i;
    for(i=StationHash.begin(); i !=StationHash.end(); ++i)
    {
    StationHash.value[i]= StationList[i];
    }

    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      If you are inserting from StationList to stationHash then stationHash is empty and your loop will never be executes.

      i is an iterator. You can not use iterator as an index.

      Why do you need a string hash that replicates a string list

      Anyway, try this
      @
      for (int i = 0; i < StationList.size(); ++i) {
      stationHash.insert(i, StationList[i])
      }
      @

      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