#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(); }
时间: 2024-11-17 12:45:58