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


C++ QTimer::setObjectName方法代码示例

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


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

示例1: onTimeout

void SignalMonitorTest::onTimeout()
{
    QTimer *tx = new QTimer(this);
    tx->setObjectName(nextTimerName());
    connect(tx, SIGNAL(timeout()), tx, SLOT(deleteLater()));
    tx->start(2500);
}
开发者ID:giucam,项目名称:GammaRay,代码行数:7,代码来源:signalmonitortest.cpp

示例2: replyFinished

void WeatherModel::replyFinished(QNetworkReply *reply)
{
    QByteArray data = reply->readAll();
    qDebug() << data;

    QJsonDocument doc = QJsonDocument::fromJson(data);

    QJsonObject query = doc.object().value("query").toObject();
    if (query.contains("results")) {
        QJsonObject res = query.value("results").toObject();
        QJsonObject cond = res.value("channel").toObject().value("item").toObject().value("condition").toObject();

        //m_results[reply->url()] = cond.value("text").toString();
        if (m_results.contains(reply->url())) {
            Report* r = m_results.value(reply->url());
            r->weather = cond.value("text").toString();
            r->lastSync = QDateTime::currentDateTime();
            emit dataChanged(createIndex(r->pos, 1),
                             createIndex(r->pos, 3));

            QTimer *t = new QTimer();
            t->setInterval(3000);
            t->setSingleShot(true);
            // Passing data in this way is simple, but not really pretty....
            t->setObjectName(reply->url().toString());
            connect(t, &QTimer::timeout,
                    this, &WeatherModel::updateData);
            t->start();
        }
    }
}
开发者ID:Combitech,项目名称:qt-course,代码行数:31,代码来源:weathermodel.cpp

示例3: initTask

void SchedulerServiceThread::initTask(QString key){

    //Aktuelle Zeit
    uint time = QDateTime::currentDateTime().toTime_t();

    //Task holen
    SchedulerServiceThread::Task *task = this->_instructions->value(key);

    //Nur auf Event reagieren
    if(!task->event.isEmpty())
        return;

    //Einmalig aber noch nicht ausgeführt?
    if(task->once && !task->done){
        //Timer anlegen und starten
        QTimer *timer = new QTimer();
        timer->setInterval((task->seconds - time) * 1000);
        timer->setObjectName("singleTimer\n"+key);
        timer->start();

        //Timer registrieren
        this->_timers.insert(key,timer);

        //Command ausführen
        connect(timer,SIGNAL(timeout()),this,SLOT(executeCommand()));
        return;
    }

    if(!task->once){
        //Timer initialisieren
        QTimer *timer = new QTimer(0);
        timer->setInterval(task->seconds * 1000);
        timer->setObjectName("timer\n"+key);
        timer->start();

        //Timer registrieren
        this->_timers.insert(key,timer);

        //Command ausführen
        connect(timer,SIGNAL(timeout()),this,SLOT(executeCommand()));
        return;
    }
}
开发者ID:okirmis,项目名称:sdb-server,代码行数:43,代码来源:schedulerservicethread.cpp

示例4: monitorFileChanged_

  void FileWatcher::monitorFileChanged_(const QString & name)
  {
    //static timer counter
    static int timer_id = 0;

    //cout << "File changed: " << String(name) << endl;
    //Look up if there is already a timer for this file
    QTimer * timer = 0;
    for (map<QString, QString>::const_iterator it = timers_.begin(); it != timers_.end(); ++it)
    {
      if (it->second == name)     //we found the timer name and id
      {
        //cout << " - Found timer name: " << String(it->second) << endl;
        //search for the timer instance with the corresponding Id
        timer = findChild<QTimer *>(it->first);
      }
    }

    //timer does not exist => create and start a new one
    if (!timer)
    {
      //cout << " - no timer found => creating a new one with name: ";
      timer = new QTimer(this);
      timer->setInterval((int)(1000.0 * delay_in_seconds_));
      timer->setSingleShot(true);
      timer->setObjectName(QString::number(++timer_id));
      connect(timer, SIGNAL(timeout()), this, SLOT(timerTriggered_()));
      timer->start();
      timers_[QString::number(timer_id)] = name;
      //cout << timer_id << endl;

    }
    //timer exists => restart it as the file changed another time
    else
    {
      //cout << " - timer found => resetting" << endl;
      timer->start();
    }
  }
开发者ID:BioITer,项目名称:OpenMS,代码行数:39,代码来源:FileWatcher.C


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