本文整理汇总了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);
}
示例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();
}
}
}
示例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;
}
}
示例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();
}
}