PDA

View Full Version : Question about signal and slots



davinciomare
5th October 2016, 20:05
Hi i have one question about this. For example different signals can be emitted at the same time and if one signal never finish wha thappen with others. The signal need to wait the other the other signal finish to start?.
When it's recommended use differents QObjects? when we need different programs or when? Thx in advance.

d_stranz
5th October 2016, 20:32
For example different signals can be emitted at the same time

No, not correct. Signals are emitted one at a time (unless there are multiple threads), but they are always handled one at a time.


if one signal never finish what happen with others

If the slot that is connected to the signal never finishes, then your program (or the thread that has the slot) will be stuck forever in that slot.


The signal need to wait the other the other signal finish to start?.

See the first answer. The slots connected to the signals are executed one after the other. A slot must finish before the next signal is handled. The Qt event loop manages the queue of signal / slot connections.


When it's recommended use differents QObjects? when we need different programs or when?

What problem are you trying to solve?

davinciomare
5th October 2016, 21:13
i am learning about hooks but i think they are very limited. because if i need to use different signals and one of this are busy with one hook. I need to do something to stop or if i dont do this i cant use the other signals.

d_stranz
5th October 2016, 21:29
It does not matter if you use hooks, slots, or anything else - if any part of your program prevents the Qt event loop from running, your program will freeze. See Wysota's article here (https://doc.qt.io/archives/qq/qq27-responsive-guis.html).

davinciomare
5th October 2016, 21:54
Thx a lot for this i will check thx again.!

d_stranz
6th October 2016, 03:59
The Qt documentation (http://doc.qt.io/qt-5/signalsandslots.html) explains it much more thoroughly.

davinciomare
6th October 2016, 11:29
ok thx a lot i will check this