Solved Question about signal and slots
-
Hi i am learning about QT and i want to understand very well the utility of this. So my question is one signal can be connected to many slots. Then for example i can run two signals at the same time. For example one signal to move one progressbar and other one button at the same time? And the slots if one is busy what happen with others? it's for solving my doubts thx
-
Hi! If you emit a signal and it's connected to many slots, then the slots are called one after another. The order of the calls can not be predicted (implementation detail).
-
@Wieland but multiple signals can be emitted so one signal need to wait the other finish to start?. And why lol when i use one signal for example to move two progressbar, the two slots move at the same time like two progressbar advance at the same time?
-
@Wieland said in Question about signal and slots:
The order of the calls can not be predicted (implementation detail).
I think this is true only across different threads
From http://doc.qt.io/qt-5/signalsandslots.html
If several slots are connected to one signal, the slots will be executed one after the other, in the order they have been connected, when the signal is emitted.
-
@VRonin Oh, interesting! Never relied on that. Thanks for the hint!
-
@RIVOPICO said
but multiple signals can be emitted so one signal need to wait the other finish to start?
Emitting a signal is nothing other than directly calling the connected slots, just like any other function call. (I'm not talking about queued connections here.)
And why lol when i use one signal for example to move two progressbar, the two slots move at the same time like two progressbar advance at the same time?
Their values don't change at the same time. But the GUI is only repainted once for all the visual changes. And even if the repainting would be done once per progressbar then it would still be much faster than you could see with your eyes.