当前位置: 首页>>代码示例>>C++>>正文


C++ QElapsedTimer::msecsTo方法代码示例

本文整理汇总了C++中QElapsedTimer::msecsTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QElapsedTimer::msecsTo方法的具体用法?C++ QElapsedTimer::msecsTo怎么用?C++ QElapsedTimer::msecsTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QElapsedTimer的用法示例。


在下文中一共展示了QElapsedTimer::msecsTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fetch

void RemoteFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, FileInfo> > &updatedFiles, const QString &path) {
    updatedFiles.append(QPair<QString, FileInfo>(fileInfo.fileName(), toFileInfo(fileInfo)));
    QElapsedTimer current;
    current.start();
    if ((firstTime && updatedFiles.count() > 100) || base.msecsTo(current) > 1000) {
        emit updates(path, updatedFiles);
        updatedFiles.clear();
        base = current;
        firstTime = false;
    }
}
开发者ID:vistle,项目名称:vistle,代码行数:11,代码来源:remotefileinfogatherer.cpp

示例2: flags

bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout)
{
    QElapsedTimer started;
    started.start();
    QElapsedTimer now = started;

    if (QAbstractEventDispatcher::instance()->inherits("QtMotif")
        || QApplication::clipboard()->property("useEventLoopWhenWaiting").toBool()) {
        if (waiting_for_data) {
            Q_ASSERT(!"QClipboard: internal error, qt_xclb_wait_for_event recursed");
            return false;
        }
        waiting_for_data = true;


        has_captured_event = false;
        capture_event_win = win;
        capture_event_type = type;

        QApplication::EventFilter old_event_filter =
            qApp->setEventFilter(qt_x11_clipboard_event_filter);

        do {
            if (XCheckTypedWindowEvent(display, win, type, event)) {
                waiting_for_data = false;
                qApp->setEventFilter(old_event_filter);
                return true;
            }

            XSync(X11->display, false);
            usleep(50000);

            now.start();

            QEventLoop::ProcessEventsFlags flags(QEventLoop::ExcludeUserInputEvents
                                                 | QEventLoop::ExcludeSocketNotifiers
                                                 | QEventLoop::WaitForMoreEvents
                                                 | QEventLoop::X11ExcludeTimers);
            QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
            eventDispatcher->processEvents(flags);

            if (has_captured_event) {
                waiting_for_data = false;
                *event = captured_event;
                qApp->setEventFilter(old_event_filter);
                return true;
            }
        } while (started.msecsTo(now) < timeout);

        waiting_for_data = false;
        qApp->setEventFilter(old_event_filter);
    } else {
        do {
            if (XCheckTypedWindowEvent(X11->display,win,type,event))
                return true;

            // process other clipboard events, since someone is probably requesting data from us
            XEvent e;
            if (XCheckIfEvent(X11->display, &e, checkForClipboardEvents, 0))
                qApp->x11ProcessEvent(&e);

            now.start();

            XFlush(X11->display);

            // sleep 50 ms, so we don't use up CPU cycles all the time.
            struct timeval usleep_tv;
            usleep_tv.tv_sec = 0;
            usleep_tv.tv_usec = 50000;
            select(0, 0, 0, 0, &usleep_tv);
        } while (started.msecsTo(now) < timeout);
    }
    return false;
}
开发者ID:BGmot,项目名称:Qt,代码行数:74,代码来源:qclipboard_x11.cpp


注:本文中的QElapsedTimer::msecsTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。