QHash

#include <QCoreApplication>
#include<QHash>
#include<QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QHash<int,QString> Employees;
    Employees.insert(1,"Bob");
    Employees.insert(2,"Cat");
    Employees.insert(3,"Boat");
    Employees.insertMulti(1,"mmm");

    qDebug()<<"3    " << Employees.value(3);

//    foreach(int i, Employees.keys())
//    {
//        qDebug() << Employees[i];
//    }

//    QHashIterator<int,QString> Iter(Employees);
//    while(Iter.hasNext())
//       {
//        Iter.next();
//        qDebug() << Iter.key()<<" "<<Iter.value();
//    }

    return a.exec();
}

  

原文地址:https://www.cnblogs.com/my-cat/p/6192887.html