What are the differences between event and signal in Qt

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

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

4条回答
  •  -上瘾入骨i
    2020-12-28 16:31

    An event is passed directly to an event handler method of a class. They are available for you to overload in your subclasses and choose how to handle the event differently. Events also pass up the chain from child to parent until someone handles it or it falls off the end.

    Signals on the other hand are openly emitted and any other entity can opt to connect and listen to them. They pass through the event loops and are processed in a queue (they can also be handled directly if they are in the same thread).

提交回复
热议问题