QMap的相关操作

来源:互联网 发布:数据库备份还原软件 编辑:程序博客网 时间:2024/05/22 00:10
 #include <QtCore/QCoreApplication>
#include <QtDebug>
#include <QString>

int main(int argc, char *argv[])
{
    QCoreApplication b(argc, argv);

    QMap<int, QString>     map;
    map.insert(4,"aaaa");
    map.insert(1,"baa");
    map.insert(2,"caaa");
    map.insert(3,"daaa");

    QString s1 = "aaaa";

    int j = map.key(s1);

    QString s = map[2];
    qDebug() << "map[2]:" << s << "\n" << "map.key(\"aaaa\"): " << j;

    return b.exec();
}

原创粉丝点击