I have 6 buttons' clicked events that I would like to connect with 6 member functions using array of pointers. I can do it like this:
QObject::connect(button_1, SIGNAL(clicked()), this, SLOT(Button1_Function()));
QObject::connect(button_2, SIGNAL(clicked()), this, SLOT(Button2_Function()));
...
But I would like to use array of pointers to buttons
and array of pointers to member functions
. How can I do it? So far I have this, but I am getting the error about No such slot
class.h
Class(){
private:
typedef void (Class::*p_buttons)(void);
p_buttons p_incr_buttons[6];
public Q_SLOTS:
void Button1_Function();
void Button2_Function();
...
}
class.cpp
Class::Class(){
p_incr_buttons = {&Class::Button1_Function, &Class::Button2_Function, ... };
for(int i=0; i<NUM_JOINTS; i++)
{
QObject::connect(incr_buttons[i], SIGNAL(clicked()), this, SLOT( (this->*(p_incr_buttons[i]))() ));
}
}
Thank you very much for your help in advance.