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

Qt Code:
  1. class Person
  2. {
  3.  
  4. public:
  5. Person( QString name, QString number );
  6.  
  7. QString m_name, m_number;
  8. };
  9.  
  10. Person::Person( QString name, QString number ) : m_name( name ), m_number( number ) {}
  11.  
  12. void hashPersons()
  13. {
  14.  
  15. QHash<int, Person*> hash;
  16. hash[12] = new Person( "Anders", "8447070" );
  17. hash[20] = new Person( "Micke", "7728433" );
  18.  
  19. QHashIterator<int, Person*> i(hash);
  20.  
  21. while (i.hasNext()) {
  22.  
  23. qDebug()<<i.key();
  24. Person *per = i.value();
  25.  
  26. qDebug()<< "Name: " << per->m_name << "Number: "<<per->m_number;
  27. i.next();
  28. }
  29. hash.clear();
  30. }
To copy to clipboard, switch view to plain text mode 
also if I call hash.clear() at the end do I need to delete the value first or clear() will take care of it ?