【发布时间】:2017-04-20 09:42:40
【问题描述】:
我尝试将 QDoubleSpinBox 信号连接到 c++11 lamda:
QObject::connect(sbox_roughness, &QDoubleSpinBox::valueChanged,
[=]() { std::cout << "value changed" << std::endl; });
这是给我的:
error: no matching function for call to ‘Game::connect(QDoubleSpinBox*&, <unresolved overloaded function type>, Game::initGui()::<lambda()>)’
[=]() { std::cout << "value changed" << std::endl; });
note: no known conversion for argument 2 from ‘<unresolved overloaded function type>’ to ‘const char*’
我试过this:
QObject::connect(sbox_roughness, static_cast<void (QDoubleSpinBox::*)(int)>(
&QDoubleSpinBox::valueChanged),
[=]() { std::cout << "value changed" << std::endl; });
给我:
error: no matches converting function ‘valueChanged’ to type ‘void (class QDoubleSpinBox::*)(int)’
&QDoubleSpinBox::valueChanged),
我在这里错过了什么?
【问题讨论】: