What are the differences between event and signal in Qt

后端 未结 4 2004
一整个雨季
一整个雨季 2020-12-28 15:56

It is hard for me to understand the difference between signals and events in Qt, could someone explain?

4条回答
  •  灰色年华
    2020-12-28 16:20

    An event is a message encapsulated in a class (QEvent) which is processed in an event loop and dispatched to a recipient that can either accept the message or pass it along to others to process. They are usually created in response to external system events like mouse clicks.

    Signals and Slots are a convenient way for QObjects to communicate with one another and are more similar to callback functions. In most circumstances, when a "signal" is emitted, any slot function connected to it is called directly. The exception is when signals and slots cross thread boundaries. In this case, the signal will essentially be converted into an event.

提交回复
热议问题