我正在使用Signal/Slot连接的新语法。对于普通信号,它可以很好地工作,但是当我尝试连接一个重载的信号时就会出现问题。
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()>)’