Qt automatically removes all connections to or from an object when it is destroyed through QObject :: ~ QObject () . Therefore, if you create a connection to a lambda when the send object is deleted, the connection is automatically cleared. You do not have and did not need to disable it yourself before.
The context object that you are accessing is used when you need finer-grained control over the lifetime of a connection. This is used when you want the connection to be deleted when another object is destroyed (context object). This makes it easy to remove the connection if you need to do this before the sender is destroyed.
In short: you do not need to manually disable the lambda, they are automatically cleared. You can use context objects to remove a connection before destroying the sender object.
source share