Several signals and single slot
-
Is there any way to connect several signals to single slot and this slot must be invoked only if ALL of that signals were emitted?
-
Yes there is a way.
You can connect all signals to one intermediate slot and connect the main to the final signal. The intermediate slot will emit the final signal only when it will receive all necessary signals. -
It doesn't work. Programm emits first signal in function 'a', the second signal in function 'b' and the third in function 'c'. I have connected this signals with intermediate slot. This slot emits signal that connected with the my main slot. What is wrong?
-
Could you show how you connected the signals and slots and how the final signal is emitted.
-
@connect(this, SIGNAL(yandexParsed()), this, SLOT(parsingFinished()));
connect(this, SIGNAL(metaParsed()), this, SLOT(parsingFinished()));
connect(this, SIGNAL(i_uaParsed()), this, SLOT(parsingFinished()));@
3 signals connected to intermediate slot parsingFinished();@connect(this, SIGNAL(pagesParsed()), this, SLOT(loadProgress()));
@slot parsingFinished() emitted signal pagesParsed() that invoked the main slot loadProgress().
During execution of a programm I have 3 invoking of the main slot but I want to have only one. -
Is loadProgress() the main slot?
Do you emit pagesParsed() on each call or you have a counter in parsingFinished()? -
loadProgress() is the main slot. Aha, so I must add a counter that will count number of calls and if this number equal to 3 only then I will invoke main slot?
-
[quote author="Giperboloid" date="1402435700"]Aha, so I must add a counter that will count number of calls and if this number equal to 3 only then I will invoke main slot?[/quote]
Yes, you are right. -
Ok, thank you. It is the only way to solve this problem, yes?
-
I'm sure there are other ways.