#include#include #include int main() { QHash myHash; myHash.insert("apple", 5); myHash.insert("banana", 7); int value = myHash.take("apple"); // remove key "apple" and return its value qDebug() << "Value of key 'apple': " << value; return 0; } Output: Value of key 'apple': 5
#includeIn both examples, QHash belongs to the QtCore package library of Qt.#include #include int main() { QHash myHash; myHash.insert("apple", 5); myHash.insert("banana", 7); int value = myHash.take("orange"); // remove key "orange" and return its value qDebug() << "Value of key 'orange': " << value; return 0; } Output: Value of key 'orange': 0