qmap判断是否存在某个key
#include <QMap>#include <QString>#include <iostream>int main() { QMap<QString, int> map; map["apple"] = 1; map["banana"] = 2; map["orange"] = 3; QString keyToCheck = "banana"; int value = map.value(keyToCheck); if (value != 0) { std::cout << "Value for key " << keyToCheck << " is: " << value << std::endl; } else { std::cout << "Key " << keyToCheck << " does not exist in the map." << std::endl; } return 0; }
========
QQ 3087438119