QMapmyMap; if (myMap.empty()) { qDebug() << "The QMap is empty"; } else { qDebug() << "The QMap is not empty"; }
QMapIn this example, we again create an empty QMap of string keys and string values. We then use the empty function to check if the QMap has been initialized or not. Since the QMap is empty, we insert a key-value pair into the map. Package library: The QMap class is part of the Qt framework library for C++.myMap; if (myMap.empty()) { myMap.insert("key1", "value1"); }