connect三种写法
函数 指针宏lambda
函数 指针
connect(sender
, &QObject
::destroyed
, this, &MyObject
::objectDestroyed
);
宏
connect(sender
, SIGNAL(destroyed(QObject
*)), this, SLOT(objectDestroyed(Qbject
*)));
connect(sender
, SIGNAL(destroyed(QObject
*)), this, SLOT(objectDestroyed()));
connect(sender
, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
函数 的 参数可忽略。
lambda
connect(sender
, &QObject
::destroyed
, [=](){ this->m_objects
.remove(sender
); });
[=] 表示用到的任何外部变量都隐式按值捕获。
转载请注明原文地址:https://ipadbbs.8miu.com/read-65003.html