IndexedTimer type

This commit is contained in:
2024-03-24 20:23:15 +03:00
parent dedd38772e
commit 47420cf19a

View File

@@ -37,6 +37,7 @@ public:
timers.clear();
}
void setIndexedTimerType(Index index, Qt::TimerType type) { timers[index].type = type; }
void bindIndexedTimer(Index index, std::function<void()> func) { timers[index].func = func; }
void stopIndexedTimer(Index index) {
auto & t(timers[index]);
@@ -52,6 +53,7 @@ public:
return;
}
t.timer = new QTimer();
t.timer->setTimerType(t.type);
QObject::connect(t.timer, &QTimer::timeout, t.func);
t.timer->start(interval.toMilliseconds());
}
@@ -67,6 +69,7 @@ private:
}
std::function<void()> func = nullptr;
QTimer * timer = nullptr;
Qt::TimerType type = Qt::CoarseTimer;
};
QMap<Index, __TimerSlot> timers;