View Full Version : Solution to one typeof "QObject : Do not delete object, xxx, during its event handler

26th October 2009, 22:02
Had to chase a bug today that was a run-time:

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

I had a subclass of QMainWindow, that I ended up turning into my own MainWindow class, which I would further subclass, as Window, in my applications.

The only message I was getting was as above and my google searches proved unfruitful so I post here what I did wrong in hope to help others.

Basically, I put a QAction in the MainWindow class and forgot to remove it from Window. So the application would compile but die right away with the wonderful QObject: Do not delete error. Took me a while to figure out the problem was quite simple, there were two QActions with the same name, one in MainWindow and one in Window. This led to the error and removing the unwanted one from Window solved the problem.

Unfortunately, I cannot explain anything about the error. Even now, having fixed it, it is not totally clear to me what Qt is trying to tell me with it.

26th October 2009, 23:42
It's more likely you were implicitly deleting some object (like a tool button tied to an action you were removing maybe) as a result of a signal (or event) originating from the object that was being deleted.