QCoreApplication :: quit()是否取消所有待处理事件?

我没有立即从QCoreApplication :: quit()的文档中清楚地看到这一点。 调用quit()插槽时是否取消了事件循环中的任何挂起事件?     
已邀请:
拨打
QCoreApplication::quit()
与拨打
QCoreApplication::exit(0)
相同。它说   调用此函数后,应用程序将离开主事件循环并从调用返回到exec()。 由于事件循环已经离开,我认为任何待处理事件都会被取消。 编辑:我做了一个小测试用例,以显示挂起的事件确实被取消:
#include <QCoreApplication>
#include <QTimer>
#include <QDebug>

class MyObject : public QObject
{
        Q_OBJECT

    public Q_SLOTS:

        void start()
        {
            QCoreApplication::postEvent(this, new QEvent(QEvent::User));
            QCoreApplication::quit();
        }

    protected:

        void customEvent(QEvent* event)
        {
            qDebug() << "Event!";
        }

};

int main(int argc, char* argv[])
{
    QCoreApplication app(argc, argv);

    MyObject o;
    QTimer::singleShot(0, &o, SLOT(start()));

    return app.exec();
}

#include "main.moc"
在这种情况下,
MyObject::start()
中发布的活动永远不会到达。当然,如果您删除对
QCoreApplication::quit()
的调用。     

要回复问题请先登录注册