PDA

View Full Version : Does it is possible to connect more than one function into a Slot ?



andre_teprom
14th August 2011, 03:04
Hi friends,


I wish know if instead above structure :

connect(_ui->buttonRecord , SIGNAL(clicked()) , this , SLOT(function1()));
Could I do something like that ?

connect(_ui->buttonRecord , SIGNAL(clicked()) , this , SLOT(function1() ;function2() ));

+++

paie
14th August 2011, 04:35
No, you cannot do that.

What are you trying to do?

You'll get more help if you're more explicit about what you are trying to do.

If you want to connect more than one signal to the same slot, well can be done two ways that I know of: with the QSignalMapper and QBuggonGroup.

ChrisW67
14th August 2011, 05:29
Did you try the obvious?


connect(_ui->buttonRecord , SIGNAL(clicked()) , this , SLOT(function1()));
connect(_ui->buttonRecord , SIGNAL(clicked()) , this , SLOT(function2()));


From QObject::connect():


A signal can be connected to many slots and signals. Many signals can be connected to one slot.

If a signal is connected to several slots, the slots are activated in the same order as the order the connection was made, when the signal is emitted.

paie
14th August 2011, 05:51
Oh, my!

I didn't know you could do that!

andre_teprom
14th August 2011, 15:37
That was exactly what I need.
I tryed and worked fine.

Thanks a lot !