【问题标题】:Passing Multiple Parameters in Slot [duplicate]在插槽中传递多个参数[重复]
【发布时间】: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]

标签: c++ qt qt5


【解决方案1】:

试试这个

QObject::connect(pushButtonKey1, &QPushButton::clicked , this, [&] 
{SetPositionKeyGUIParameters(1 , layoutProperty); });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-10
    • 2011-07-06
    • 2013-07-08
    • 2020-03-12
    • 2015-05-11
    • 1970-01-01
    • 2011-05-08
    • 2012-01-08
    相关资源
    最近更新 更多