PDA

View Full Version : [Basic question] Signals & Slot



GortiZ
1st April 2008, 09:37
Hi to all,
I'm starting with QT4 and I need to connect an "int" signal to a "double" slot.
I've tried with:

QSpinBox::connect(mw_ui->spinbox_LineNumber, SIGNAL(valueChanged(int)), &(*mw_ui->qwtSlider_LineNumber), SLOT(setValue(double)));

but I receive the message:
Incompatible sender/receiver...

I've searched on google how to solve this problem.. but I havn't find nothing..
could someone help me?
Thanks
GortiZ

^NyAw^
1st April 2008, 09:54
Hi,

You can't connect a signal that emits a type and a slot that recives another type.

Read the doc about signals and slots.

GortiZ
1st April 2008, 10:11
I've already readed that I can't connect different types, but I need to change the value in the spinbox with the one in the slider so i'm asking if there's a way to do this or a workaround to make this working..

Thanks for the answer

wysota
1st April 2008, 10:15
Create a custom slot and connect the signal to it and from the custom slot simply call the original slot as a regular function.

GortiZ
1st April 2008, 10:37
sorry i'm a newbye.. could you link me to a page where i can find a documentation on how to create custom slots?

Thanks a lot

wysota
1st April 2008, 10:39
It's all in Qt's documentation. Read the tutorial there.