[Interest] Using connect/disconnect with lambdas

Nikos Chantziaras realnc at gmail.com
Mon Feb 19 06:28:40 CET 2018


On 19/02/18 06:59, Tom Isaacson via Interest wrote:
> But how do I disconnect a lambda?
>      disconnect(m_pRouteEditNameAct, &tAction::triggered, this, [this]() { RouteEditName(); });
> 
> This seems like it's trying to disconnect from a different lambda to the one I originally connected to.

Store the connection:

   class Blah {
       QMetaObject::Connection connection;
   };

   connection = connect(/* ... */);

You can then disconnect it with:

   disconnect(connection);




More information about the Interest mailing list