QT connect signal 和 slot 类型匹配
需求 qt 在使用 connect 连接时,有些时候因为类型匹配的问题,会报错: QPushButton * controller_button_[APP_NUM_OF_CONTROLLER]; QSignalMapper * signalMapper_; signalMapper_ = new QSignalMapper(this); for (int i = 0; i < APP_NUM_OF_CONTROLLER; i++) { controller_button_[i] = new QPushButton(this); connect(controller_button_[i], &QPushButton::clicked, signalMapper_, &QSignalMapper::map); signalMapper_->setMapping(controller_button_[i], i); } connect(signalMapper_, &QSignalMapper::mapped, this, &MainWindow::ClickDetail); mainwindow.cpp:173:9: error: no matching member function for call to 'connect' qobject.h:222:36: note: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool) __attribute__((thiscall))' to 'const char *' for 2nd argument qobject....