I have a class member:
QSet<QDialog*>* dialogs_;
Do I need to delete just dialogs_ or do I have to call delete on each element of it as well?
I have a class member:
QSet<QDialog*>* dialogs_;
Do I need to delete just dialogs_ or do I have to call delete on each element of it as well?
This will do the trick:
qDeleteAll(*dialogs_);
delete dialogs_
You can also do it without dereference:
qDeleteAll(dialogs_->begin(), dialogs->end());
delete dialogs_
Yes, you need to somehow manually delete each QDialog in dialogs_, if it has any.
You can iterate through the QSet and delete them manually yourself. Because QDialog inherits from QWidget, another way is to simply delete the parent of all the dialogs if the parent is allocated on the free store as well, which will in turn delete them.
Note that there's no reason to allocate QSet on the free store, if that's what you're doing. You can save a new/delete operation by simply making it a direct member of your class.
QSet<QDialog*> dialogs_;
That's one less thing you have to worry about w.r.t. manual deletion.
First iterate through your set, delete every object in it, and then delete the set object.
However, take a note that Qt has it's own memory management, and it might be ok just to delete the set, and leave the objects in it to be destructed by the Qt's mechanism.