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. QMultiMap strange behavior

QMultiMap strange behavior

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 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.
  • _ Offline
    _ Offline
    _Mark_
    wrote on last edited by
    #1

    Please, look at this code:

    @
    QMultiMap<QString, int> map;
    map.insert("a", 0);
    map.insert("a", 1);

    QList<int> values = map.values("a");
    //qDebug() << values.size();
    for (int i = 0; i < values.size(); i++) qDebug() << values.at(i);
    

    @

    With qDebug() << values.size() commented it prints out only the first value of the key "a".
    If I enable the qDebug() of the values.size() it prints out both values!

    Qt5.3 under linux arm (RPi).
    Any idea?

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

      Hi,

      On OS X with 5.4, it works as expected

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        I don't see why it would not work, but if it doesn't, it seems to me the problem would be in QList, not in QMultiMap right? However, due to the very core nature of QList and the fact that it is used everywhere, I find it extremely unlikely that it would faulty in such basic behaviour. More likely something a clean complile would solve, I think.

        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