Qt 4.5 - Is emitting signal a function call, or a thread, and does it blocks?

后端 未结 3 1763
再見小時候
再見小時候 2021-01-31 03:03

I am not sure about the nature of the signal/slot mechanism in Qt 4.5. When a signal is emitted, is it a blocking function call or a thread? Say this

emit GrabLa         


        
3条回答
  •  逝去的感伤
    2021-01-31 03:13

    It depends. From the documentation:

    When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call. When this happens, the signals and slots mechanism is totally independent of any GUI event loop. Execution of the code following the emit statement will occur once all slots have returned. The situation is slightly different when using queued connections; in such a case, the code following the emit keyword will continue immediately, and the slots will be executed later.

    So in normal cases, it will be synchronous and blocking, and with queued connections it will be asynchronous and non-blocking.

提交回复
热议问题