信号与槽 之 如果多个信号指向同一个槽函数
如果多个信号指向同一个槽函数,想知道是触发的是哪个信号。
contect(colorPushBtn, SIGNAL(clicked()), this, SLOT(doPushBtn()));
contect(errorPushBtn, SIGNAL(clicked()), this, SLOT(doPushBtn()));
// colorPushBtn 和colorPushBtn是不同的按钮。想知道是哪个按钮,
QPushButton *btn = qobject_cast<QPushButton*>(sender());
if (btn == colorPushBtn) {
// 颜色对话框
}