zoukankan      html  css  js  c++  java
  • qt exec

    int QApplication::exec()
    {
    #ifndef QT_NO_ACCESSIBILITY
        QAccessible::setRootObject(qApp);
    #endif
        return QCoreApplication::exec();
    }

    int QCoreApplication::exec()
    {
        if (!QCoreApplicationPrivate::checkInstance("exec"))
            return -1;

        QThreadData *threadData = self->d_func()->threadData;
        if (threadData != QThreadData::current()) {
            qWarning("%s::exec: Must be called from the main thread", self->metaObject()->className());
            return -1;
        }
        if (!threadData->eventLoops.isEmpty()) {
            qWarning("QCoreApplication::exec: The event loop is already running");
            return -1;
        }

        threadData->quitNow = false;
        QEventLoop eventLoop;
        self->d_func()->in_exec = true;
        self->d_func()->aboutToQuitEmitted = false;
        int returnCode = eventLoop.exec();
        threadData->quitNow = false;
        if (self) {
            self->d_func()->in_exec = false;
            if (!self->d_func()->aboutToQuitEmitted)
                emit self->aboutToQuit();
            self->d_func()->aboutToQuitEmitted = true;
            sendPostedEvents(0, QEvent::DeferredDelete);
        }

        return returnCode;
    }

    eventLoop.exec();------》

    while (!d->exit)
        processEvents(flags | WaitForMoreEvents | EventLoopExec);

    bool QEventLoop::processEvents(ProcessEventsFlags flags)
    {
        Q_D(QEventLoop);
        if (!d->threadData->eventDispatcher)
            return false;
        if (flags & DeferredDeletion)
            QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
        return d->threadData->eventDispatcher->processEvents(flags);
    }

    进一步:这将调用平台相关的函数,比如:

    bool QEventDispatcherQWS::processEvents(QEventLoop::ProcessEventsFlags flags)    bool QGuiEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)

    int QApplication::qwsProcessEvent(QWSEvent* event)

  • 相关阅读:
    Opencv+C++之身份证识别(一)
    Opencv 提取图像中的矩形区域
    Opencv+C++之人脸识别二
    Perl 中的正则表达式
    Convert asio::streambuf to std::string
    WM_IDLEUPDATECMDUI与CView
    使用Boost的Regex库
    字符串编码方式的趣味介绍
    转: 20100711小强热线曝本田CRV、日产逍客没有车尾防撞钢梁(片子前面是所有车型回顾)
    对话框使用ON_UPDATE_COMMAND_UI(转)
  • 原文地址:https://www.cnblogs.com/cute/p/2231263.html
Copyright © 2011-2022 走看看