我在线程的run()
函数的代码主体中发现,直到退出应用程序,exec()
(https://doc.qt.io/qt-5/qapplication.html#exec)之后的代码才会实现。例如:
myClass::run()
{
qDebug()<<"Before exec()";
//do some work, e.g., signal-slot connections based on a QTimer object
exec();
qDebug()<<"After exec()"; //this piece of code is implemented only after the application is quitted.
}
我想知道这种观察是通用的还是仅适用于某些情况。有人可以为我解释吗?谢谢。
答案 0 :(得分:0)
According to Qt doc ( https://doc.qt.io/qt-5/qthread.html#exec)时,如何设置自动向我发送电子邮件,exec()
意味着进入事件循环并等待直到调用exit() 。这可能是为什么退出应用程序后实现exec()
之后的代码的原因。