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. Can i use QHash.toMap?
Forum Updated to NodeBB v4.3 + New Features

Can i use QHash.toMap?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.3k 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.
  • S Offline
    S Offline
    Simplevolk
    wrote on last edited by
    #1

    Hello!
    can i converte QHash to QMap?

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

      Not directly, but the code to make the conversion is trivial I'd say.

      Something like this should do the trick:
      @
      //sample only, code completely untested.
      template <typename Key, typename Value>
      QMap<Key, Value> hashToMap(const QHash<Key, Value> hash) {
      QMap<key, Value> result;
      QHashIterator<Key, Value> it(hash);
      while (it.hasNext()) {
      it.next();
      result.insert(it.key(), it.value());
      }
      return result;
      }
      @

      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