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();
}

  

posted @ 2016-12-17 18:41  mCat  Views(444)  Comments(0Edit  收藏  举报