Hi,
I started playing with QHash, but I cant make hashPersons function to enumerate all keys and value since its crashing and I don't know why, please help :(
also if I call hash.clear() at the end do I need to delete the value first or clear() will take care of it ?Code:
class Person { public: QString m_name, m_number; }; void hashPersons() { QHash<int, Person*> hash; hash[12] = new Person( "Anders", "8447070" ); hash[20] = new Person( "Micke", "7728433" ); QHashIterator<int, Person*> i(hash); while (i.hasNext()) { qDebug()<<i.key(); Person *per = i.value(); qDebug()<< "Name: " << per->m_name << "Number: "<<per->m_number; i.next(); } hash.clear(); }
