void SharedTimerQt::timerEvent(QTimerEvent* ev) { if (!m_timerFunction || ev->timerId() != m_timer.timerId()) return; m_timer.stop(); (m_timerFunction)(); }
void toggleRunning() { if (timer.isActive()) timer.stop(); else { timer.start(10, this); el.start(); } }
void Worker::timerEvent(QTimerEvent * ev) { const int busyTime = 50; // [ms] - longest amount of time to stay busy const int testFactor = 128; // number of iterations between time tests const int maxCounter = 10000; if (ev->timerId() != m_timer.timerId()) return; QElapsedTimer t; t.start(); while (1) { // do some "work" Helper::usleep(100); m_counter ++; // exit when the work is done if (m_counter > maxCounter) { emit progress(100); emit done(); m_busy = false; break; } // exit when we're done with a timed "chunk" of work // Note: QElapsedTimer::elapsed() may be expensive, so we call it once every testFactor iterations if ((m_counter % testFactor) == 1 && t.elapsed() > busyTime) { emit progress(m_counter*100/maxCounter); break; } } }
void timerEvent(QTimerEvent *ev) override { if (ev->timerId() == timer.timerId() && painter) { qreal const t = el.restart() / (qreal)10; for (auto &s : state) s.advance(t, dst.rect()); update(); } }
static PyObject *meth_QBasicTimer_isActive(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QBasicTimer *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QBasicTimer, &sipCpp)) { bool sipRes; Py_BEGIN_ALLOW_THREADS sipRes = sipCpp->isActive(); Py_END_ALLOW_THREADS return PyBool_FromLong(sipRes); } }
void SharedTimerQt::start(double fireTime) { double interval = fireTime - currentTime(); unsigned int intervalInMS; if (interval < 0) intervalInMS = 0; else { interval *= 1000; intervalInMS = (unsigned int)interval; } m_timer.start(intervalInMS, this); }
void timerEvent(QTimerEvent * ev) override { if (ev->timerId() != m_timer.timerId()) return; int timeout = m_app->m_timeout; auto now = QDateTime::currentMSecsSinceEpoch(); m_toEmit.clear(); QMutexLocker lock(&m_app->m_mutex); for (auto it = m_app->m_threads.begin(); it != m_app->m_threads.end(); ++it) { if (it->ping == 0) continue; qint64 elapsed = now - it->ping; it->stuck = elapsed > timeout; m_toEmit.push_back({it.key(), it->stuck ? elapsed : 0}); } lock.unlock(); for (auto &sig : qAsConst(m_toEmit)) emit m_app->loopStateChanged(sig.thread, sig.elapsed); }
explicit StuckEventLoopNotifier(MonitoringApp * app) : m_app(app) { m_timer.start(100, Qt::CoarseTimer, this); }
void Start (int interval) { if (!Timer_.isActive ()) Timer_.start (interval, this); }
void Stop () { Timer_.stop (); }
Q_SLOT void start() { if (m_busy) return; m_counter = 0; m_busy = true; m_timer.start(0, this); }
void startTicker(QObject *object) { if (!ticker.isActive()) ticker.start(15, object); timeCounter.start(); }
UIQT(QWidget *parent = {}) : QWidget(parent) { m_layout.addWidget(&m_label, 0, 0); m_timer.start(500, this); refreshImage(); }
void timerEvent(QTimerEvent *ev) override { if (ev->timerId() == m_timer.timerId()) refreshImage(); }
Q_SLOT void on_lineEdit_textEdited() { if (m_queryBehavior == FinalQuery || !m_queryTimer.isActive()) m_queryTimer.start(100, this); }
void SharedTimerQt::stop() { m_timer.stop(); }
void timerEvent(QTimerEvent * ev) { if (ev->timerId() != m_queryTimer.timerId()) return; m_queryTimer.stop(); emit queryRequest(); }