What is an event loop in Qt?

蹲街弑〆低调 提交于 2019-11-29 22:46:09

问题


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

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.

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?


回答1:


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.

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



来源:https://stackoverflow.com/questions/40880949/what-is-an-event-loop-in-qt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!