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


C++ QTime::secsTo方法代码示例

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


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

示例1: QTime

int Tano::Xmltv::timeZoneDiff()
{
    QDateTime local = QDateTime::currentDateTime();
    local.setTime(QTime(0, 0));
    QDateTime utc = local.toUTC();
    local.setTimeSpec(Qt::LocalTime);
    QDateTime offset = local.toUTC();
    QTime properTimeOffset = QTime(offset.time().hour(), offset.time().minute());
    offset.setTimeSpec(Qt::LocalTime);
    utc.setTimeSpec(Qt::UTC);

    bool isNegative;
    if (offset.secsTo(utc) < 0) {
        isNegative = true;
    } else {
        isNegative = false;
        properTimeOffset.setHMS(24 - properTimeOffset.hour() - (properTimeOffset.minute()/60.0) - (properTimeOffset.second()/3600.0), properTimeOffset.minute() - (properTimeOffset.second()/60.0), properTimeOffset.second());
        if (!properTimeOffset.isValid()) { //Midnight case
            properTimeOffset.setHMS(0,0,0);
        }
    }

    if (isNegative)
        return properTimeOffset.secsTo(QTime(0, 0));
    else
        return - properTimeOffset.secsTo(QTime(0, 0));
}
开发者ID:ntadej,项目名称:tano,代码行数:27,代码来源:XmltvCommon.cpp

示例2: UpdateWaitTime

// --------stay()函数待补充 ---------
void Passenger::UpdateWaitTime(VTime* t) // 不断更新当前乘客的等待时间,如果等待时间超出最大忍耐时限会发出leave()信号
{
    QTime current = t->GetCurVTime();
    int waitTime = - current.secsTo(requestTime);
    if(waitTime >= tolerationTime)
        emit leave(this);  // 向楼层发出“离开”信号  -> 楼层接到该信号后应将该乘客从等待链表中删去。
}
开发者ID:acDante,项目名称:Simulation,代码行数:8,代码来源:passenger.cpp

示例3: changed

void
MetaQueryWidget::numValue2Changed( const QTime& value )
{
    m_filter.numValue2 = qAbs( value.secsTo( QTime(0,0,0) ) );

    emit changed(m_filter);
}
开发者ID:phalgun,项目名称:amarok-nepomuk,代码行数:7,代码来源:MetaQueryWidget.cpp

示例4: processCache

void PendingFileQueue::processCache()
{
    QTime currentTime = QTime::currentTime();

    for (const PendingFile& file : qAsConst(m_cache)) {
        if (file.shouldRemoveIndex()) {
            Q_EMIT removeFileIndex(file.path());

            m_recentlyEmitted.remove(file.path());
            m_pendingFiles.remove(file.path());
        }
        else if (file.shouldIndexXAttrOnly()) {
            Q_EMIT indexXAttr(file.path());
        }
        else if (file.shouldIndexContents()) {
            if (m_pendingFiles.contains(file.path())) {
                QTime time = m_pendingFiles[file.path()];

                int secondsLeft = currentTime.secsTo(time);
                secondsLeft = qBound(m_minTimeout, secondsLeft * 2, m_maxTimeout);

                time = currentTime.addSecs(secondsLeft);
                m_pendingFiles[file.path()] = time;
            }
            else if (m_recentlyEmitted.contains(file.path())) {
                QTime time = currentTime.addSecs(m_minTimeout);
                m_pendingFiles[file.path()] = time;
            }
            else {
                if (file.isNewFile()) {
                    Q_EMIT indexNewFile(file.path());
                } else {
                    Q_EMIT indexModifiedFile(file.path());
                }
                m_recentlyEmitted.insert(file.path(), currentTime);
            }
        } else {
            Q_ASSERT_X(false, "FileWatch", "The PendingFile should always have some flags set");
        }
    }

    m_cache.clear();

    if (!m_pendingFiles.isEmpty() && !m_pendingFilesTimer.isActive()) {
        m_pendingFilesTimer.setInterval(m_minTimeout * 1000);
        m_pendingFilesTimer.start();
    }

    if (!m_recentlyEmitted.isEmpty() && !m_clearRecentlyEmittedTimer.isActive()) {
        m_clearRecentlyEmittedTimer.setInterval(m_trackingTime * 1000);
        m_clearRecentlyEmittedTimer.start();
    }
}
开发者ID:stream009,项目名称:baloo,代码行数:53,代码来源:pendingfilequeue.cpp

示例5: toTimeChanged

void SplitVideo::toTimeChanged( const QTime & )
{
    QTime t;
    m_endTime = t.secsTo( ui->teTo->time() );

    qDebug( "SplitVideo::toTimeChanged:    m_endTime = %d", m_endTime );

    // correct time
    if ( m_startTime > m_endTime )
        m_startTime = m_endTime;

    updateTime();
}
开发者ID:AlexRu,项目名称:rosa-media-player,代码行数:13,代码来源:splitvideo.cpp

示例6: QDialog

QTipDlg::QTipDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QTipDlg)
{
    ui->setupUi(this);
    QDesktopWidget *dwsktopwidget = QApplication::desktop();
    QRect screenrect = dwsktopwidget->screenGeometry();
//    qCritical("screenrect.w==%s\n",qPrintable(QString::number(screenrect.width())));
//    qCritical("screenrect.h==%s\n",qPrintable(QString::number(screenrect.height())));

    QString imgStyle = "border-image: url(:/pic/pic/background";
    QString imgStr = ".jpg);";
    int picNo = qrand()%10+1;
    this->ui->graphicsView->setStyleSheet(imgStyle+QString::number(picNo)+imgStr);


    this->setGeometry(screenrect.width()-500+160,screenrect.height()-240-60,300,240);
    this->setWindowFlags(Qt::FramelessWindowHint);

    QTime nowTime = QTime::currentTime();
    int nowHour = nowTime.hour();
    QTime targetTime = QTime(nowHour,59,59);//到下一个 整点时钟

    int seconds = nowTime.secsTo(targetTime)+1;

    ui->labelTime->setText("现在是北京时间"+nowTime.toString("hh点mm分"));
    QString secs = QString::number(seconds,10);

    ui->labelTip->setText("请休息一下吧  ");
}
开发者ID:blackfool,项目名称:Qtip,代码行数:30,代码来源:qtipdlg.cpp

示例7: multipleClientsAtOnceTest

void TestSingleSignon::multipleClientsAtOnceTest()
{
    QList<SsoClientThread *> clientThreads;

    QTime startTime = QTime::currentTime();
    for(int i = 0; i < m_numberOfTestClients; i++)
    {
        qDebug() << "\n\nCreating SSO test client thread...\n\n";
        SsoClientThread *thread = new SsoClientThread(SsoTestClient::AllTests);
        thread->start();
        clientThreads.append(thread);
    }

    SsoClientThread *thread = NULL;
    bool done = false;

    //this assumes all client threads will be finished at a certain point
    while(!done)
    {
        int finishedThreadsCount = 0;
        foreach(thread, clientThreads)
            if(thread->isFinished()) ++finishedThreadsCount;

        done = ((finishedThreadsCount == m_numberOfTestClients) ? true : false);
        sleep(1);
    }

    while(!clientThreads.empty())
        if(SsoClientThread *thread = clientThreads.takeFirst()) delete thread;

    QTime endTime = QTime::currentTime();
    int elapsed = startTime.secsTo(endTime);
    qDebug() << QString("TestSingleSignon::multipleClientsAtOnceTest() ---- TIME --> Total elapsed time: %1 seconds.\n\n").arg(elapsed);
}
开发者ID:maemo-foss,项目名称:accounts-sso-signon,代码行数:34,代码来源:testsinglesignon.cpp

示例8: processPendingFiles

void PendingFileQueue::processPendingFiles()
{
    QTime currentTime = QTime::currentTime();
    int nextUpdate = m_maxTimeout;

    QMutableHashIterator<QString, QTime> it(m_pendingFiles);
    while (it.hasNext()) {
        it.next();

        int secondsLeft = currentTime.secsTo(it.value());
        if (secondsLeft <= 0) {
            Q_EMIT indexModifiedFile(it.key());
            m_recentlyEmitted.insert(it.key(), currentTime);

            it.remove();
        }
        else {
            nextUpdate = qMin(secondsLeft, nextUpdate);
        }
    }

    if (!m_pendingFiles.isEmpty()) {
        m_pendingFilesTimer.setInterval(nextUpdate * 1000);
        m_pendingFilesTimer.start();
    }

    if (!m_recentlyEmitted.isEmpty() && !m_clearRecentlyEmittedTimer.isActive()) {
        m_clearRecentlyEmittedTimer.setInterval(m_trackingTime * 1000);
        m_clearRecentlyEmittedTimer.start();
    }
}
开发者ID:stream009,项目名称:baloo,代码行数:31,代码来源:pendingfilequeue.cpp

示例9: rp

void
ScriptEngine::resolve( const Tomahawk::query_ptr& query )
{
    qDebug() << Q_FUNC_INFO << query->toString();
    QString eval = QString( "resolve( '%1', '%2', '%3', '%4' );" )
                      .arg( query->id().replace( "'", "\\'" ) )
                      .arg( query->artist().replace( "'", "\\'" ) )
                      .arg( query->album().replace( "'", "\\'" ) )
                      .arg( query->track().replace( "'", "\\'" ) );

    QList< Tomahawk::result_ptr > results;

    QVariantMap m = mainFrame()->evaluateJavaScript( eval ).toMap();
    qDebug() << "JavaScript Result:" << m;

    const QString qid = query->id();
    const QVariantList reslist = m.value( "results" ).toList();

    foreach( const QVariant& rv, reslist )
    {
        QVariantMap m = rv.toMap();
        qDebug() << "RES" << m;

        Tomahawk::result_ptr rp( new Tomahawk::Result() );
        Tomahawk::artist_ptr ap = Tomahawk::Artist::get( 0, m.value( "artist" ).toString() );
        rp->setArtist( ap );
        rp->setAlbum( Tomahawk::Album::get( 0, m.value( "album" ).toString(), ap ) );
        rp->setTrack( m.value( "track" ).toString() );
        rp->setBitrate( m.value( "bitrate" ).toUInt() );
        rp->setUrl( m.value( "url" ).toString() );
        rp->setSize( m.value( "size" ).toUInt() );
        rp->setScore( m.value( "score" ).toFloat() * ( (float)m_parent->weight() / 100.0 ) );
        rp->setRID( uuid() );
        rp->setFriendlySource( m_parent->name() );

        if ( m.contains( "year" ) )
        {
            QVariantMap attr;
            attr[ "releaseyear" ] = m.value( "year" );
            rp->setAttributes( attr );
        }

        rp->setDuration( m.value( "duration", 0 ).toUInt() );
        if ( rp->duration() <= 0 && m.contains( "durationString" ) )
        {
            QTime time = QTime::fromString( m.value( "durationString" ).toString(), "hh:mm:ss" );
            rp->setDuration( time.secsTo( QTime( 0, 0 ) ) * -1 );
        }

        rp->setMimetype( m.value( "mimetype" ).toString() );
        if ( rp->mimetype().isEmpty() )
        {
            rp->setMimetype( TomahawkUtils::extensionToMimetype( m.value( "extension" ).toString() ) );
            Q_ASSERT( !rp->mimetype().isEmpty() );
        }

        results << rp;
    }
开发者ID:tdfischer,项目名称:tomahawk,代码行数:58,代码来源:qtscriptresolver.cpp

示例10: timetableSlotFromTime

int LoggingWindow::timetableSlotFromTime(QTime time) {
    int returnInt;
    if (time.secsTo(*this->p1) > 0) {
        returnInt = 0;
    }
    else if (time.secsTo(*this->p2) > 0) {
        returnInt = 1;
    }
    else if (time.secsTo(*this->form) > 0) {
        returnInt = 2;
    }
    else if (time.secsTo(*this->p3) > 0) {
        returnInt = 3;
    }
    else if (time.secsTo(*this->p4) > 0) {
        returnInt = 4;
    }
    else if (time.secsTo(*this->lunch) > 0) {
        returnInt = 5;
    }
    else if (time.secsTo(*this->p5) > 0) {
        returnInt = 6;
    }
    else {
        returnInt = 7;
    }
    return returnInt;

}
开发者ID:yobson,项目名称:Smell-Detector,代码行数:29,代码来源:loggingwindow.cpp

示例11: DiferencaEntreHoras

QTime Funcoes::DiferencaEntreHoras(QTime hora1, QTime hora2)
{
    QTime diferenca(0, 0, 0);

    if( hora1 < hora2 )
        diferenca = diferenca.addSecs( hora1.secsTo( hora2 ) );

    return diferenca;
}
开发者ID:escrifonife1,项目名称:Almoco,代码行数:9,代码来源:funcoes.cpp

示例12: parseTimeString

/**
 * Parse a time value from the provided string.
 *
 * @param value The text to be parsed
 * @param ok Pointer to a boolean value which will represent the success or
 *           failure of the parsing attempt
 * @return The number of seconds after midnight in the parsed time, shown as
 *         a string
 */
QString Formatting::parseTimeString(const QString &value, bool *ok)
{
    // check for imported blank
    if (value.isEmpty()) {
        *ok = true;
        return "-1";
    }
    int length = value.length();
    int firstColon = value.indexOf(':');
    if (firstColon == -1) {
        // assume it's a number of seconds, as used internally
        int totalSeconds = value.toInt(ok);
        if (!(*ok) || totalSeconds < -1 || totalSeconds > 86399) {
            *ok = false;
        }
        return value;
    }
    // from here on is used only when importing
    if (firstColon < 1 || length < firstColon + 3) {
        *ok = false;
        return value;
    }
    int hours = value.left(firstColon).toInt(ok);
    if (!(*ok)) {
        return value;
    }
    int minutes = value.mid(firstColon + 1, 2).toInt(ok);
    if (!(*ok)) {
        return value;
    }
    int seconds = 0;
    int secondColon = value.indexOf(':', firstColon + 1);
    if (secondColon != -1 && length > secondColon + 2) {
        seconds = value.mid(secondColon + 1, 2).toInt(ok);
        if (!(*ok)) {
            return value;
        }
    }
    if (value.indexOf("pm", 0, Qt::CaseInsensitive) != -1) {
        if (hours < 12) {
            hours += 12;
        }
    }
    else if (value.indexOf("am", 0, Qt::CaseInsensitive) != -1 && hours == 12) {
        hours = 0;
    }
    QTime time;
    if (!time.setHMS(hours, minutes, seconds)) {
        *ok = false;
        return value;
    }
    QTime midnight;
    int totalSeconds = midnight.secsTo(time);
    *ok = true;
    return QString::number(totalSeconds);
}
开发者ID:jmbowman,项目名称:portabase,代码行数:65,代码来源:formatting.cpp

示例13: slot_SaveList

//保存当前列表
void MusicList::slot_SaveList()
{
	QString fileName = QFileDialog::getSaveFileName(this, tr("保存播放列表"), tr("播放列表"), tr("*.m3u *.pls"));
	if (!fileName.isEmpty())
	{
		ofstream file(fileName.toStdString());

		QString strSuffixName = fileName.right(3);//得到后缀名
		if (strSuffixName == "m3u" || strSuffixName == "M3U")
		{
			file << "#EXTM3U" << endl;			//表示一个M3U文件
		}
		else if (strSuffixName == "pls" || strSuffixName == "PLS")
		{
			file << "[playlist]" << endl;		//表示一个pls文件
		}

		vector<MusicListSaveFormatEntity> vec;
		if (DBModule::readMusicListSaveFormatEntity(vec))
		{
			int i = 0;
			foreach (MusicListSaveFormatEntity entity, vec)
			{
				++i;
				QTime qTime;
				int nTime = qTime.secsTo(QTime::fromString(QString::fromStdString(entity.getTime()), "mm:ss"));

				if (strSuffixName == "m3u" || strSuffixName == "M3U")
				{
					QString sFileName = QString::fromStdString(entity.getFileName());
					QString strMusicName = "";
					if (sFileName.contains(" - "))
					{
						strMusicName = sFileName.split(" - ").at(1);
					}
					file << "#EXTINF:" << nTime << "," << strMusicName.toStdString() << "\n" << entity.getFilePath() << endl;
				}
				else if (strSuffixName == "pls" || strSuffixName == "PLS")
				{
					QString sFileName = QString::fromStdString(entity.getFileName());
					QString strMusicName = "";
					if (sFileName.contains(" - "))
					{
						strMusicName = sFileName.split(" - ").at(1);
					}
					file << "File" << i << "=" << entity.getFilePath() << "\n"
						 << "Title" << i << "=" << strMusicName.toStdString() << "\n"
						 << "Length" << i << "=" << nTime << endl;
				}
			}
			if (strSuffixName == "pls" || strSuffixName == "PLS")
			{
				file << "NumberOfEntries=" << i <<  endl;
			}
		}
开发者ID:keygen8-git,项目名称:CZPlayer2.0,代码行数:56,代码来源:musiclist.cpp

示例14: refreshConnectedSince

void TreeButton::refreshConnectedSince()
{
    this->timer.stop();

    if (Preferences::instance()->isVisible()) {
        QDate cDate (this->getParentItemCast()->getOpenVPN()->getConnectedSinceDate());
        QTime cTime (this->getParentItemCast()->getOpenVPN()->getConnectedSinceTime());

        // Nun die Zet ermitteln
        int diffDays (cDate.daysTo(QDate::currentDate()));
        int diffSeconds (cTime.secsTo(QTime::currentTime()));

        int hours (0);
        int minutes (0);
        int seconds (0);
        if (diffSeconds < 0) {
            // Bei einem negativen Ergebniss liegt die Zeit in der Zukunft,
            // es muss aber in der Vergangeheit liegen, es kann ein neuer Tag sein
            // Sekunden zurücksetzen
            diffSeconds = 0;
            this->getParentItemCast()->getOpenVPN()->setConnectedSinceTime(QTime::currentTime());
        }

        if (diffSeconds >= 3600) {
            // Stunden sind da
            // Stunden ermitteln
            hours = (int) diffSeconds / 3600;
            // Neuen Rest
            diffSeconds = diffSeconds - (3600 * hours);
            if (diffDays > 0) {
                // Tage auf Stunden rechnen
                hours = hours + diffDays * 24;
            }
        }
        // Minuten da?
        if (diffSeconds >= 60) {
            minutes = (int) diffSeconds / 60;
            // Neuen Rest ermitteln
            diffSeconds = diffSeconds - (minutes * 60);
        }

        // Sind noch Sekunden übrig?
        if (diffSeconds > 0) {
            seconds = diffSeconds;
        }

        // Alles ermittelt nun setzen
        this->getParentItem()->setText(1, this->getParentItemCast()->getOpenVPN()->getConfigName()
                                          + QLatin1String ("\n") + (hours < 10 ? "0" : "") + QString::number(hours)
                                          + QLatin1String (":") + (minutes < 10 ? "0" : "") + QString::number(minutes)
                                          + QLatin1String (":") + (seconds < 10 ? "0" : "") + QString::number(seconds));
    }

    this->timer.start();
}
开发者ID:OldFrank,项目名称:openvpn-client,代码行数:55,代码来源:treebutton.cpp

示例15: singleTestClient

void TestSingleSignon::singleTestClient()
{
    QTime startTime = QTime::currentTime();

    SsoTestClient client;
    client.runAllTests();

    QTime endTime = QTime::currentTime();
    int elapsed = startTime.secsTo(endTime);
    qDebug() << QString("TestSingleSignon::singleTestClient() ---- TIME --> Total elapsed time: %1 seconds.\n\n").arg(elapsed);
}
开发者ID:maemo-foss,项目名称:accounts-sso-signon,代码行数:11,代码来源:testsinglesignon.cpp


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