stdmap with at () value, if the key does not exist, I'm sorry, crash. QMap () with the value value, if the key does not exist, it does not crash, you can also specify a default value

I think the best thing to upgrade is Qt6 container class

stdmap when traversal, and very easy to get key and value:

for (var & Auto: the Map) {
    qDebug () << << var.first var.second;
}

but it QMap I can not do so convenient.

for (I = qmap.begin Auto ();! I = qmap.end (); I ++) {
    qDebug () << i.key () << i.value ();
}

But honestly, little changed containers beating.

Of course, I still recommend using Qt libraries own container.
Because in the value of, QMap the more than stdmap shy.

stdmap with at () value, if the key does not exist, sorry, the program crashes
QMap with value () value, if the key does not exist, does not crash, you can also specify a default value

http://www.qtcn.org/bbs/read-htm-tid-86101.html

Guess you like

Origin www.cnblogs.com/findumars/p/11514363.html