I want to assign three button's slot to a signal.
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);
};
I do this in constructor:
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)));
but when I run program in wrote:
QObject::connect: No such slot MainWindow::clickmee(int) in ..\Qsignal2\mainwindow.cpp:11 QObject::connect: (receiver name: 'MainWindow')
How can I assign slots to signal ? How can I send parameter to a slot ?
EDIT: I want to do this:
void setclick1(int x)
{
if(x== 10)
{
// ....
}
else
{
// ...
}
}
but this function not firing. How can I do that?