2

a simple question, as the QT manual don't specifically state it; the QT manual mention the the De-constructor does it, but not deletelater().

When we invoke deletelater() on an object, does it disconnect all it signals and slots registration as well?

Gilco
  • 1,326
  • 12
  • 13

1 Answers1

3

Not exactly. The deleteLater() slot schedules the object for deletion. In other words, it will be deleted once control goes back to the event loop.

However, the signals and slots are disconnected once the QObject's destructor is called. To quote the destructor's the documentation:

All signals to and from the object are automatically disconnected...

See also this similar Stack Overflow question: Qt Signals and Slots object disconnect?

Community
  • 1
  • 1
MrEricSir
  • 8,044
  • 4
  • 30
  • 35
  • I understand that, but what I am missing, does deletelater() call the destructor when it delete the object? – Gilco Dec 28 '14 at 04:18
  • @Gilco Yes and no -- `deleteLater()` simply calls `delete`. In C++ `delete` automatically calls the destructor. – MrEricSir Dec 28 '14 at 04:42