I'm trying to use QObject
tree delete mechanism to delete the list and all QObject
s that are stored in the list. Qt is still my very week area...
QList<QObject*>* list = new QList<QObject*>();
QObject* obj1 = new QObject();
QObject* obj2 = new QObject();
obj1->setParent(obj2);
obj2->setParent((QObject*)list);
I got "Segmentation fault" at last line. Can't the QList
be used as a parent? Doesn't it inherit from QObject
?
Edit:
The main question - is it possible to conveniently delete the list and all list elements without extending the QList
class? This need to be called by client so it have to be simple.
I would like to simply call:
delete list;
and not
qDeleteAll(list);
delete list;
QList<QObject*> list
? – Jan Kundrát