我想将三个按钮的插槽分配给一个信号。
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QSignalMapper *signalmapper;
Ui::MainWindow *ui;
void test(int);
signals:
void clickmee(int);
public slots:
void setclick1(int);
void setclick2(int);
void setclick3(int);
};
我在构造函数中这样做:
signalmapper = new QSignalMapper(this);
signalmapper->setMapping(ui->pushButton, 10);
signalmapper->setMapping(ui->pushButton1, 10);
signalmapper->setMapping(ui->pushButton1, 10);
connect(signalmapper, SIGNAL(mapped(int)),this,SLOT(clickmee(int)));
但是当我运行程序时写道:
QObject::connect: No such slot MainWindow::clickmee(int) in ..\Qsignal2\mainwindow.cpp:11 QObject::connect: (receiver name: 'MainWindow')
如何将插槽分配给信号?如何将参数发送到插槽?
编辑:我想这样做:
void setclick1(int x)
{
if(x== 10)
{
// ....
}
else
{
// ...
}
}
但这个功能没有触发。我怎样才能做到这一点?