Originally Posted by
mchara
but if parent is removed first(and removes child) and then child is removed explicitly,
It is not removed explicitly. By explicit I mean that you delete it manually instead of letting Qt handle that.
then we have wrong pointer there.
No.
#include <QApplication>
#include <QWidget>
int main(int argc, char **argv){
parent->setAttribute(Qt::WA_DeleteOnClose);
chld->setAttribute(Qt::WA_DeleteOnClose);
parent->show();
return app.exec();
}
#include <QApplication>
#include <QWidget>
int main(int argc, char **argv){
QApplication app(argc, argv);
QWidget *parent = new QWidget(0);
parent->setAttribute(Qt::WA_DeleteOnClose);
QWidget *chld = new QWidget(parent);
chld->setAttribute(Qt::WA_DeleteOnClose);
parent->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
The above code works just fine.
And what if both generate deleteLater events on hide?
That's exactly what happens with the attribute set.
Is it managed on the level of event loop?
Yes, the event loop handles that.
If hide event is called on parent, it calls hide on child, and both generates deleteLater events,
so if then delete event of parent would be processed (and delete also child), child's delete event is already queued...
But it doesn't get executed. When an object is deleted, pending events are discarded (that's not exactly what happens, but the result is valid).
By the way wysota,
Great article about undo/redo framework in qt quarterly
Thanks. It looked much worse before they corrected the language
Bookmarks