首页 > 代码库 > QMap

QMap

#include <QCoreApplication>
#include<QMap>
#include<QDebug>

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

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

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

    return a.exec();
}

  

QMap