【发布时间】:2019-07-26 04:59:25
【问题描述】:
我试图在 Slot 中发送两个参数,但出现以下错误。
'layoutProperty' 不能被隐式捕获,因为没有指定默认捕获模式
'layoutProperty' 是一个 QVBoxLayout。
void Container::CreatePositionAnimationUI(QHBoxLayout *layout1 ,
QHBoxLayout *layout2 , QHBoxLayout *layout3 , QVBoxLayout
*layoutProperty )
{
QPushButton *pushButtonKey1 = new QPushButton;
QPushButton *pushButtonKey2 = new QPushButton;
QPushButton *pushButtonKey3 = new QPushButton;
layout1->addWidget(pushButtonKey1);
layout2->addWidget(pushButtonKey2);
layout3->addWidget(pushButtonKey3);
QObject::connect(pushButtonKey1, &QPushButton::clicked , this,
[this] {SetPositionKeyGUIParameters(1 ,layoutProperty); }); // Get error on this line
}
【问题讨论】:
-
更改为
[this, layoutProperty]