QMapmyMap; myMap.insert("apple", 3); myMap.insert("orange", 5); myMap.insert("banana", 2); int value = myMap.value("orange"); // value is 5
QMapIn this example, another QMap is created that stores integers as keys and strings as values. The `[]` operator is used to insert and retrieve key-value pairs. The QMap class is a part of the Qt Core module.myMap; myMap[1] = "one"; myMap[2] = "two"; myMap[3] = "three"; QString value = myMap[2]; // value is "two"