最近遇到个问题,如果不用SIGNAL,SLOT的连接方式,想在connect中使用lamda表达式,那怎么区分控件的重载的消息函数呢?
可以这样做,先给重载的消息函数重命名,例如,给QCombobox中的currentIndexChanged(int index)重命名,
typedef void(QComboBox::*IntIndexChange)(int);
然后在调用的地方这样写,
connect(box, (IntIndexChange)&QComboBox::currentIndexChanged, this,[=,this](int currentIndex)
{
m_CurBoxViewType = eType;
viewChange(currentIndex);
});
就搞定了。