什么是Qt中的事件循环? [英] What is an event loop in Qt?

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

问题描述

对于QApplication的 exec 函数,我了解以下内容:

I have understood the following regarding QApplication's exec function:


QApplication exec启动主事件循环。
它启动GUI。它处理信号并在接收信号时调用适当的插槽。它一直等到调用exit并返回在exit中设置的值。

QApplication exec starts the main event loop. It launches the GUI. It processes the signals and calls appropriate slots on receiving them. It waits until exit is called and returns the value which was set in exit.

现在,当我们说事件循环时,是否意味着是否在Qt的内部代码中运行了while循环,并且在while循环中编写了处理信号和时隙的方法?

Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop the method of handling signals and slots is written?

推荐答案


现在,当我们说事件循环时,是否意味着在Qt的内部代码中有一些while
循环在运行,而while循环中

Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop the method of handling signals and slots is written?

从某种意义上说,是这样。如今,大多数软件坐下来等待事件(用户输入,网络流量,计时器事件,传感器等)并做出相应的响应。

In a sense, yes. Most software these days sits and waits for events -- user input, network traffic, timer events, sensors, etc. -- and responds accordingly.

这不是Qt特有的。从Windows到Android到Arduino,到处都是这种常见的设计模式。

This is not specific to Qt. It's a common design pattern you'll find everywhere from Windows to Android to Arduino.

这篇关于什么是Qt中的事件循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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