QMap

西北逍遥發表於2024-10-02

  QMap<QString, int> map;

map["one"] = 1;
map["three"] = 3;
map["seven"] = 7;

map.insert("twelve", 12);

int num1 = map["thirteen"];
int num2 = map.value("thirteen");

int timeout = 30;
if (map.contains("TIMEOUT"))
      timeout = map.value("TIMEOUT");

  QMapIterator<QString, int> i(map);
  while (i.hasNext()) {
      i.next();
      cout << i.key() << ": " << i.value() << endl;
  }

####################################