在《The book of Qt4》上看到这么一段话:
The call to
exec() starts the event loop which is in charge of forwarding application events to the appropriate objects.Such events are caused by user actions, such as clicking a
button.
The event loop is terminated when the quit() function of the QApplication object is called.
还有这么一句话:Finally we start the event loop
and pass the return code from the event loop back as the application's return value. A simple return 0; would terminate the application immeditately without even display the
window.
比如下面这个例子:
- #include <QApplication>
- #include <QLabel>
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- QLabel label("Hello World");
- label.show();
-
- return a.exec();
- }
求大家帮忙通过这个小程序解释下循环机制。
是a.exec()开始事件循环吗?那return a.exec()与结束的花括号之间是如何
执行的?
return a.exec()是指a.exec()这个事件循环返回一个值,然后通过return 这个值来结束程序?