使用Qt5的新信号/插槽实现发信号通知一个sliderReleased()

时间:2017-05-10 18:53:36

标签: c++ c++11 qt5

我正在使用基于以下链接的示例

Passing an argument to a slot

我尝试在释放某个滑块时将某个功能与给定参数连接。

connect(m_customUIForm.horizontalSliderOr, &QAbstractSlider::sliderReleased(), this, [this]{ sendMoveActuator(1); });

问题似乎在于信号&QAbstractSlider::sliderReleased()

error: cannot call member function 'void QAbstractSlider::sliderReleased()' without object
 connect(m_customUIForm.horizontalSliderOr, &QAbstractSlider::sliderReleased(), this, [this]{ sendMoveActuator(1); });

传递sliderReleased()的信号的正确方法是什么?

                                                                             ^

1 个答案:

答案 0 :(得分:0)

查看链接帖子中的示例,我建议您删除括号。即不:

connect(m_customUIForm.horizontalSliderOr, &QAbstractSlider::sliderReleased(), this, [this]{ sendMoveActuator(1); });

而是:

connect(m_customUIForm.horizontalSliderOr, &QAbstractSlider::sliderReleased, this, [this]{ sendMoveActuator(1); });