Qt 中的事件循环是什么?

What is an event loop in Qt?(Qt 中的事件循环是什么?)
本文介绍了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?

推荐答案

现在,当我们说事件循环时,是否意味着有一些while在 Qt 的内部代码中运行的循环,在那个 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 中的事件循环是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Bring window to front -gt; raise(),show(),activateWindow() don’t work(把窗户放在前面 -raise(),show(),activateWindow() 不起作用)
How to get a list video capture devices NAMES (web cameras) using Qt (crossplatform)? (C++)(如何使用 Qt(跨平台)获取列表视频捕获设备名称(网络摄像机)?(C++))
How to compile Qt as static(如何将 Qt 编译为静态)
C++ over Qt : Controlling transparency of Labels and Buttons(C++ over Qt:控制标签和按钮的透明度)
How to know when a new USB storage device is connected in Qt?(Qt如何知道新的USB存储设备何时连接?)
How to implement a video widget in Qt that builds upon GStreamer?(如何在基于 GStreamer 的 Qt 中实现视频小部件?)