PDA

View Full Version : how can i destruct QHash<QString, QPixmap>?



SamSong
7th February 2010, 03:48
hi, all, I use i memeber QHash<QString,QPixmap> in my class ,but when the object is destructed ,it wrong,how can i destruct it.

class CommElement
{
public:
CommElement()
{

}
~CommElement()
{
//qDeleteAll(m_picManager);
//m_picManager.clear();

}

void loadPictures(QDataStream &s) //return the picture path which have been handle
{
s>>m_picManager;
}

QHash<QString,QPixmap> pictureManager()
{
return m_picManager;
}

private:
QHash<QString,QPixmap> m_picManager;
};

aamer4yu
7th February 2010, 06:41
For QHash<QString,QPixmap> you wont need to delete the object since it will get created on stack.
if you had pointers in ur map , something like QHash<QString,QPixmap*> , then you would need to delete them using qDeleteAll()