【发布时间】:2015-09-18 19:15:35
【问题描述】:
我正在为信号/插槽连接使用新语法。它对我来说很好,除非我尝试连接过载的信号。
MyClass : public QWidget
{
Q_OBJECT
public:
void setup()
{
QComboBox* myBox = new QComboBox( this );
// add stuff
connect( myBox, &QComboBox::currentIndexChanged, [=]( int ix ) { emit( changedIndex( ix ) ); } ); // no dice
connect( myBox, &QComboBox::editTextChanged, [=]( const QString& str ) { emit( textChanged( str ) ); } ); // this compiles
}
private:
signals:
void changedIndex( int );
void textChanged( const QString& );
};
不同之处在于 currentIndexChanged 是重载的(int 和 const QString& 类型),但 editTextChanged 不是。非过载信号连接良好。超载的不会。我想我错过了什么?使用 GCC 4.9.1,我得到的错误是
no matching function for call to ‘MyClass::connect(QComboBox*&, <unresolved overloaded function type>, MyClass::setup()::<lambda()>)’
【问题讨论】: