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. [Solved] Ordering Problem with QMap
Forum Updated to NodeBB v4.3 + New Features

[Solved] Ordering Problem with QMap

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

    Hi guys.
    I have ordering problem with QMap. I've googled it but my problem didn't solved.
    Suppose I have QMap<QString,int>. After i insert some values into QMap the ordering is not kept. I didn't find any substitution option.
    Is there any (key, value) pairs container class int Qt that keep the ordering of keys.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      Hi,

      The items are always sorted by key, while iterating over a QMap. "read documentation":http://qt-project.org/doc/qt-5.0/qtcore/qmap.html#details

      You can have a look at "this":http://qt-project.org/forums/viewthread/19394 thread for the required implementation.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alizadeh91
        wrote on last edited by
        #3

        Thanks :) I used QList<QPair<T1,T2> > and that's ok :)

        1 Reply Last reply
        1

        • Login

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