PDA

View Full Version : Signal/Slot connection failing



Polnareff
15th July 2010, 19:42
Hi,

I have a class and dll structure similar to the following...


Specific.dll

class Form
- contains a Controller *mController
- contains a CustomDoubleSpinBox*mCustomDoubleSpinBox

class Controller
- has signal MySignal(double,double,double)


Common.dll

class CustomDoubleSpinBox
- derives from QDoubleSpinBox
- has slot MySlot(double, double, double)


In the Form class, I create the following connection:

connect( mController, SIGNAL(MySignal(double,double,double)), mCustomSpinBox, SLOT(MySlot(double,double,double)));
This connection fails. The error I get in the output window is:


Object::connect: No such slot QDoubleSpinBox::MySlot(double,double,double)
I am able to call the slot function normally, and the slot is a member of CustomDoubleSpinBox, not QDoubleSpinBox as is printed in the output...

I'm not quite sure why this is happening...perhaps it has to do with the signal and slot being in different DLLs?

All help is greatly appreciated :) Thanks!

Zlatomir
15th July 2010, 20:03
That error is when you run the program?
Most likely you forgot to declare MySlot(...) with "public slots:" access specifier

franz
15th July 2010, 20:06
This would suggest that the custom double spin box doesn't have the slot properly defined. If it was, the name would have ended up in a list of strings during mocing.

The signal/slot system is basically a nifty way of calling functions. DLL boundaries have no effect on it (Qt does cross dll all the time).

Polnareff
15th July 2010, 20:41
I did define it with public slots...but franz just made me realize perhaps I needed to re-build my project...and then further made me realize I never added the Q_OBJECT macro to my class :p

Thanks for the help!