Qt中的事件和信号之间有什么区别 [英] What are the differences between event and signal in Qt

查看:357
本文介绍了Qt中的事件和信号之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解Qt中信号和事件之间的区别,有人可以解释吗?

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

推荐答案

事件是封装在类(QEvent)中的消息,该类在事件循环并分派给可以接受消息或将其传递给其他人进行处理的收件人.它们通常是为响应外部系统事件(例如鼠标单击)而创建的.

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.

信号和插槽QObject相互通信的一种便捷方式,它与回调函数类似.在大多数情况下,发出信号"时,将直接调用与其连接的任何插槽功能.例外是当信号和插槽跨越线程边界时.在这种情况下,信号实际上将转换为事件.

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.

这篇关于Qt中的事件和信号之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆