QVariantMap myMap; myMap.insert("key1", "value1"); myMap.insert("key2", 42); myMap.insert("key3", QSize(640, 480));
QString value1 = myMap["key1"].toString(); int value2 = myMap["key2"].toInt(); QSize value3 = myMap["key3"].value();
foreach(QString key, myMap.keys()) { QVariant value = myMap[key]; qDebug() << "Key:" << key << "Value:" << value; }This iterates over each key-value pair in the QVariantMap and prints them to the console. The QVariantMap class is part of the QtCore package library.