i want to build a pointer to a Qt Slot:
union {
void (*set_slot)(unsigned long value);
void (*refresh_slot)(void);
} the_slot;
The slot definition is:
void set_pwm(unsigned long new_pwm);
I try to do something like this:
the_slot.set_slot = set_pwm;
But the compiler says that the signature does not match:
error: argument of type
voidvoid (*)(long
(DriverBoard::)(long unsigned
int)' does not match
unsigned int)’
hint: the slot is in class DriverBoard
Any idea where my error is?
And if someone knows – is it possible to do something like that with signals also?
Thanks!
Simon
Slots and signals are identified by their names (when you do use
SLOT(set_pwm(unsigned long))in your code, you are constructing a string). You can simply store the name and the object and then call the slot usingQMetaObject.You can use pointers to member functions in C++ (see the C++ faq), but in this case I’d suggest to use Qt’s meta object system.