Qt 如何使用 lambda 表达式连接信号和槽?

时间:2022-10-05 19:12:22
connect(camera, static_cast<void(QCamera::*)(QCamera::LockStatus, QCamera::LockChangeReason)>(&QCamera::lockStatusChanged),
      [=](QCamera::LockStatus status, QCamera::LockChangeReason reason){ /* ... */ });


static_cast<void(QCamera::*)(QCamera::LockStatus, QCamera::LockChangeReason)>(&QCamera::lockStatusChanged)
上面这句是一个静态转换 static_cast<>()

QCamera::* 是类指针
QCamera::LockStatus 函数参数
QCamera::LockChangeReason 函数参数
&QCamera::lockStatusChanged 函数地址