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. QList of QHash values

QList of QHash values

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 706 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.
  • ZgemboZ Offline
    ZgemboZ Offline
    Zgembo
    wrote on last edited by Zgembo
    #1

    HI all,

    I am trying to figure out how to create simple list of QHash values. What I need is
    QHash<QString , int> and put it into QList over which I need to iterate.

    I have tried this

    QHash<QString, bool> fileNames;
    QList<QHash<QString, bool>> list;

    fileNames.insert("One", true);
    fileNames.insert("Two", false);
    fileNames.insert("Three", true);
    
    list << fileNames;
    
    for(int i = 0; i < list.size(); i++)
        qDebug() << list.at(i);
    

    But I do not know how to iterate over this list.

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @Zgembo hi, see alo QPair

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

        Hi,

        What exact trouble do you have ?

        QHash<QString, bool> hash = list.at(index); will get you the object of a specific index. Or do you mean using iterators ?

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

        ZgemboZ 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          What exact trouble do you have ?

          QHash<QString, bool> hash = list.at(index); will get you the object of a specific index. Or do you mean using iterators ?

          ZgemboZ Offline
          ZgemboZ Offline
          Zgembo
          wrote on last edited by
          #4

          @SGaist said in QList of QHash values:

          Hi,

          What exact trouble do you have ?

          QHash<QString, bool> hash = list.at(index); will get you the object of a specific index. Or do you mean using iterators ?

          @SGaist thank you.

          1 Reply Last reply
          0
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by
            #5

            Hope the issue is resolved as suggested. You can move the issue to SOLVED.

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            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