PDA

View Full Version : Can I send a signal with several parameters to a slot with only one parameter?



ricardo
3rd May 2009, 12:40
Hi dudes!

Can I send a signal with several parameters to a slot with only one parameter?
Is this possible:
connect(d, SIGNAL(valueThreeIntegersChanged(int,int,int)), this, SLOT(UpdateSecondInteger(int)));
How can I choose which parameter I send? (Let's say I'd like to send the 2nd param to this slot)


Thanks for help.

jpn
3rd May 2009, 13:06
Hi dudes!
Hi



Can I send a signal with several parameters to a slot with only one parameter?
Is this possible:
connect(d, SIGNAL(valueThreeIntegersChanged(int,int,int)), this, SLOT(UpdateSecondInteger(int)));

Yes, it's possible.



How can I choose which parameter I send? (Let's say I'd like to send the 2nd param to this slot)

You can't. It will be always the first one. The leftover parameters will be ignored. You can implement an intermediate slot that will call UpdateSecondInteger() with desired parameters, though.

ricardo
3rd May 2009, 13:59
You can implement an intermediate slot that will call UpdateSecondInteger() with desired parameters, though.

Thanks for reply. How can I do it?

jpn
3rd May 2009, 14:15
I meant something like this:


connect(d, SIGNAL(valueThreeIntegersChanged(int,int,int)), this, SLOT(intermediateSlot(int,int,int)));

void Foo::intermediateSlot(int a, int b, int c)
{
Q_UNUSED(a);
Q_UNUSED(c);
UpdateSecondInteger(b);
}