#include#include int main() { QMap map; map.insert(1, "One"); map.insert(2, "Two"); map.insert(3, "Three"); std::cout << "Value of key 2 is: " << map.value(2) << std::endl; return 0; }
#includeIn the above example, string key-value pairs are stored in QMap using the [] operator. The value of key "Two" is accessed using the [] operator. Package/library: Qt#include int main() { QMap map; map["One"] = 1; map["Two"] = 2; map["Three"] = 3; std::cout << "Value of key \"Two\" is: " << map["Two"] << std::endl; return 0; }