1. Lambda写法
非重载函数
QCheckBox *checkBox1 = new QCheckBox("check box1");
connect(checkBox1,&QCheckBox::stateChanged, [=](int state) {
m_statusBar->showMessage(QString("%1 state changed %2").arg(checkBox1->text()).arg(state));
});
重载函数
这里,QComboBox有两个重载的currentIndexChanged函数
需要强制类型转化一下
QComboBox *comboBox1 = new QComboBox();
connect(comboBox1, static_cast<void(QComboBox::*)(int index)>(&QComboBox::currentIndexChanged), this, [=](int index) {
m_statusBar->showMessage("");
});