PDA

View Full Version : QObject : Do not delete object, 'unnamed', during its event handler



aaron
19th July 2009, 07:43
Hi all,
I have a new question need you help.
In the mainwindow, I have a button to close a sub-window, and its shortcut is "ctrl + w"
when I click this button, the program works ok, but if I use its shortcut, there is an information:
"QObject: Do not delete object, 'unname' , during its event handler" .When I close this sub-window, I will delete some object to release memory, when delete the object which inherits QGraphicsView, this information will occur.
If you have some addvice, please help me ,thanks!

caduel
19th July 2009, 07:52
This means (as the message says) that you delete some object while one of its events is being processed. You should not do that.
Use deleteLater() instead. See, QObject::deleteLater().

HTH

aaron
19th July 2009, 11:44
Hi caduel,
Thanks for your help firstly !
According to your advice, I fix the bug, thanks again !