Reputation: 63
Is a QT connection constructed by the connect()
statement automatically cleaned up, when its creator ( for example a QAction) is deleted, or must I do this on my own, by saving connections
as instances of my class and deleting them in my destructor?
Given is the following example:
MYClass::MYClass() {
connect(this, &QAction::triggered, this, &MYClass::clicked);
}
Upvotes: 1
Views: 583
Reputation: 10827
The documentation for the destructor of QObject
says
All signals to and from the object are automatically disconnected
here: https://doc.qt.io/qt-5/qobject.html#dtor.QObject
So no you don't have do disconnect your connections. When any QObject object is destructed it will clean this up for you.
Upvotes: 5