#include#include int main() { QHash hash; hash.insert("apple", 5); hash.insert("banana", 7); hash.insert("orange", 3); hash.clear(); return 0; }
#includeIn this example, a new hash table is created with string keys and integer values. Before calling the clear() function, the isEmpty() function is used to check if the hash table is empty or not. If it is not empty, the clear() function is called. Package Library: Qt5Core.#include int main() { QHash hash; hash.insert("apple", 5); hash.insert("banana", 7); hash.insert("orange", 3); if (!hash.isEmpty()) { hash.clear(); } return 0; }