Use new connect syntax in DoAfter()

This commit is contained in:
Jonas Kvinge 2021-01-30 14:27:25 +01:00
parent 60528525e0
commit ebf6ba9ca1
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ void Unpack(QList<QGenericArgument>*) {}
} // namespace _detail
_detail::ClosureBase* NewClosure(QObject *sender, const char *signal, std::function<void()> callback) {
_detail::ClosureBase *NewClosure(QObject *sender, const char *signal, std::function<void()> callback) {
return new _detail::CallbackClosure(sender, signal, callback);
}

View File

@ -227,7 +227,7 @@ template <typename R, typename P>
void DoAfter(std::function<void()> callback, std::chrono::duration<R, P> duration) {
QTimer *timer = new QTimer;
timer->setSingleShot(true);
NewClosure(timer, SIGNAL(timeout()), callback);
QObject::connect(timer, &QTimer::timeout, callback);
QObject::connect(timer, &QTimer::timeout, timer, &QTimer::deleteLater);
std::chrono::milliseconds msec = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
timer->start(msec.count());