View Full Version : will QHash::remove call delete?
jajdoo
19th July 2011, 12:32
i have:
QHash<QString, polly::Element*> _children;
(polly::element being a class of my own)
i want to remove an item from the hash and be sure its dead - the internet has me confused about this one.. will remove call delete for me?
mcosta
19th July 2011, 13:17
You're storing a pointer to polly::Element so you have to delete yourself.
nish
19th July 2011, 13:36
just make a call like this to remove and delete
delete _childern.take(key);
jajdoo
19th July 2011, 13:41
EDIT: late response, nish answered
which one is the better option?
( element is also a QObject - just noticed that my QHash of children logically clashes with the QObject's having a children list already.. )
delete _children.take( name );
_children.value( name )->deleteLater();
_children.remove( name );
delete _children.value( name );
_children.remove( name );
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.