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


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

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


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

示例1: onStateChartCycle

void DefaultStateChartDriver::onStateChartCycle()
{

    //void
    m_sc->runCycle();
    if (m_sc->getDefaultSCI()->isRaised_heartbeat())
    {
    	static QElapsedTimer timer;
    	if (timer.isValid())
    		qDebug() << "heartbeat :" << timer.elapsed() << "/ 1000";
        timer.restart();
    }
    if (m_sc->getDefaultSCI()->isRaised_footstomp())
    {
    	static QElapsedTimer timer;
    	if (timer.isValid())
    		qDebug() << "footstomp :"  << timer.elapsed() << "/300";
        timer.restart();
    }
    if (m_sc->getDefaultSCI()->isRaised_fingertap())
    {
    	static QElapsedTimer timer;
    	if (timer.isValid())
    		qDebug() << "fingertap :"  << timer.elapsed() << "/ 215";
        timer.restart();
    }

    if (m_sc->getDefaultSCI()->isRaised_done())
    {
        qDebug() << "done";
        QCoreApplication::quit();
    }
}
开发者ID:aboseley,项目名称:YakinduQTimer,代码行数:33,代码来源:DefaultStateChartDriver.cpp

示例2: validity

void tst_QElapsedTimer::validity()
{
    QElapsedTimer t;

    QVERIFY(!t.isValid()); // non-POD now, it should always start invalid

    t.start();
    QVERIFY(t.isValid());

    t.invalidate();
    QVERIFY(!t.isValid());
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:12,代码来源:tst_qelapsedtimer.cpp

示例3: gitProgressCB

extern "C" int gitProgressCB(bool reset, const char *text)
{
	static QElapsedTimer timer;
	static qint64 lastTime;
	static QString lastText;
	static QMLManager *self;
	static int lastPercent;

	if (!self)
		self = QMLManager::instance();

	if (!timer.isValid() || reset) {
		timer.restart();
		lastTime = 0;
		lastPercent = 0;
		lastText.clear();
	}
	if (self) {
		qint64 elapsed = timer.elapsed();
		// don't show the same status twice in 200ms
		if (lastText == text && elapsed - lastTime < 200)
			return 0;
		self->loadDiveProgress(++lastPercent);
		QString logText = QString::number(elapsed / 1000.0, 'f', 1) + " / " + QString::number((elapsed - lastTime) / 1000.0, 'f', 3) +
				  QString(" : git %1 (%2)").arg(lastPercent).arg(text);
		self->appendTextToLog(logText);
		qDebug() << logText;
		if (elapsed - lastTime > 500)
			qApp->processEvents();
		lastTime = elapsed;
	}
	// return 0 so that we don't end the download
	return 0;
}
开发者ID:rainzhangtime,项目名称:subsurface,代码行数:34,代码来源:qmlmanager.cpp

示例4: monotonicallyIncreasingTime

double monotonicallyIncreasingTime()
{
    ASSERT(QElapsedTimer::isMonotonic());
    static QElapsedTimer timer;
    if (!timer.isValid())
        timer.start();
    return timer.nsecsElapsed() / 1.0e9;
}
开发者ID:anger123520,项目名称:qtwebkit-23_from_gitorious,代码行数:8,代码来源:CurrentTime.cpp

示例5: currentTimeForEvent

static inline double currentTimeForEvent(const QInputEvent* event)
{
    Q_ASSERT(event);

    if (event->timestamp())
        return static_cast<double>(event->timestamp()) / 1000;

    static QElapsedTimer timer;
    if (!timer.isValid())
        timer.start();
    return static_cast<double>(timer.elapsed()) / 1000;
}
开发者ID:zhao07,项目名称:qtwebengine,代码行数:12,代码来源:web_event_factory.cpp

示例6: runTest

void FuzzyTester::runTest(const QString &profile, const QString &startCommit,
                          int maxDurationInMinutes, int jobCount, bool log)
{
    m_profile = profile;
    m_jobCount = jobCount;
    m_log = log;

    runGit(QStringList() << "rev-parse" << "HEAD", &m_headCommit);
    qDebug("HEAD is %s", qPrintable(m_headCommit));

    qDebug("Trying to find a buildable commit to start with...");
    const QString workingStartCommit = findWorkingStartCommit(startCommit);
    qDebug("Found buildable start commit %s.", qPrintable(workingStartCommit));
    QStringList allCommits = findAllCommits(workingStartCommit);
    qDebug("The test set comprises all %d commits between the start commit and HEAD.",
           allCommits.size());

    // Shuffle the initial sequence. Otherwise all invocations of the tool with the same start
    // commit would try the same sequence of commits.
    std::srand(std::time(nullptr));
    std::random_shuffle(allCommits.begin(), allCommits.end());

    quint64 run = 0;
    QStringList buildSequence(workingStartCommit);
    QElapsedTimer timer;
    const qint64 maxDurationInMillis = maxDurationInMinutes * 60 * 1000;
    if (maxDurationInMillis != 0)
        timer.start();

    bool timerHasExpired = false;
    while (std::next_permutation(allCommits.begin(), allCommits.end()) && !timerHasExpired) {
        qDebug("Testing permutation %llu...", ++run);
        const auto &allCommitsImmutable = allCommits;
        for (const QString &currentCommit : allCommitsImmutable) {
           if (timer.isValid() && timer.hasExpired(maxDurationInMillis)) {
               timerHasExpired = true;
               break;
           }

            m_currentCommit = currentCommit;
            buildSequence << currentCommit;
            checkoutCommit(currentCommit);
            qDebug("Testing incremental build #%d (%s)", buildSequence.size() - 1,
                   qPrintable(currentCommit));

            // Doing "resolve" and "build" separately introduces additional possibilities
            // for errors, as information from change tracking has to be serialized correctly.
            QString qbsError;
            m_currentActivity = resolveIncrementalActivity();
            bool success = runQbs(defaultBuildDir(), QLatin1String("resolve"), &qbsError);
            if (success) {
                m_currentActivity = buildIncrementalActivity();
                success = runQbs(defaultBuildDir(), QLatin1String("build"), &qbsError);
            }
            m_currentActivity = buildFromScratchActivity();
            if (success) {
                if (!doCleanBuild(&qbsError)) {
                    QString message = "An incremental build succeeded "
                                      "with a commit for which a clean build failed.";
                    if (!m_log) {
                        message += QString::fromLatin1("\nThe qbs error message "
                                "for the clean build was: '%1'").arg(qbsError);
                    }
                    throwIncrementalBuildError(message, buildSequence);
                }
            } else {
                qDebug("Incremental build failed. Checking whether clean build works...");
                if (doCleanBuild()) {
                    QString message = "An incremental build failed "
                                      "with a commit for which a clean build succeeded.";
                    if (!m_log) {
                        message += QString::fromLatin1("\nThe qbs error message for "
                                "the incremental build was: '%1'").arg(qbsError);
                    }
                    throwIncrementalBuildError(message, buildSequence);
                } else {
                    qDebug("Clean build also fails. Continuing.");
                }
            }
        }
    }

    if (timerHasExpired)
        qDebug("Maximum duration reached.");
    else
        qDebug("All possible permutations were tried.");
}
开发者ID:BumblingCoder,项目名称:qbs,代码行数:87,代码来源:fuzzytester.cpp


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