I've got a QMap with the QString key and with value pointer to an Object of myclass. But I don't know how to delete a pointer from QMap when I allocate the value of QMap dynamically:
QMap<QString, myClass*> types;
myClass *type = types.value(typeKey);
if (!type) {
type = new myClass;
types.insert(typeKey, type);
How shall I delete a pointer by a key?
I'm aware of QMap methods like remove
. Is that safe to use?
What about the following:
const QString key = types.key(static_cast<myClass*>());
types.remove(key);