PDA

View Full Version : many signals, one slot



eric
23rd January 2008, 20:43
Is it possible to connect may signals to one slot automatically with only 1 signal/slot construct?

I have 6 radiobuttons and I'd like all of them to trigger the same slot. Do I have to have 6 separate signal/slot declarations or is it possible to somehow achieve it all with just one signal/slot? Perhaps there is a way to group all of these radiobuttons together somehow and treat this group as one signal?

jpn
23rd January 2008, 21:07
See QButtonGroup.

elcuco
23rd January 2008, 21:35
See: QObject::sender()

eric
23rd January 2008, 21:49
Thanks!
Are there any examples for the QObject::sender() posted somewhere. The documentation didn't make it clear to me how to use it.

ashukla
24th January 2008, 07:04
Thanks!
Are there any examples for the QObject::sender() posted somewhere. The documentation didn't make it clear to me how to use it.
See the link mentioned below;
http://doc.trolltech.com/4.3/qsignalmapper.html#details

jpn
24th January 2008, 07:25
Are there any examples for the QObject::sender() posted somewhere. The documentation didn't make it clear to me how to use it.
What kind of example would you expect? It returns a pointer to the QObject who sent the signal. You can compare it to a member variable or something:


void MyClass::mySlot()
{
if (myButton == sender())
{
// mybutton sent the signal
}
}