Qt 中的事件循环是什么?
What is an event loop in Qt?
关于 QApplication 的 exec
功能,我已经了解以下内容:
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 特有的。这是一种常见的设计模式,从 Windows 到 Android 再到 Arduino 随处可见。
关于 QApplication 的 exec
功能,我已经了解以下内容:
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 特有的。这是一种常见的设计模式,从 Windows 到 Android 再到 Arduino 随处可见。