Use new connect syntax in DoAfter()
This commit is contained in:
parent
60528525e0
commit
ebf6ba9ca1
@ -64,7 +64,7 @@ void Unpack(QList<QGenericArgument>*) {}
|
|||||||
|
|
||||||
} // namespace _detail
|
} // 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);
|
return new _detail::CallbackClosure(sender, signal, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ template <typename R, typename P>
|
|||||||
void DoAfter(std::function<void()> callback, std::chrono::duration<R, P> duration) {
|
void DoAfter(std::function<void()> callback, std::chrono::duration<R, P> duration) {
|
||||||
QTimer *timer = new QTimer;
|
QTimer *timer = new QTimer;
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
NewClosure(timer, SIGNAL(timeout()), callback);
|
QObject::connect(timer, &QTimer::timeout, callback);
|
||||||
QObject::connect(timer, &QTimer::timeout, timer, &QTimer::deleteLater);
|
QObject::connect(timer, &QTimer::timeout, timer, &QTimer::deleteLater);
|
||||||
std::chrono::milliseconds msec = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
|
std::chrono::milliseconds msec = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
|
||||||
timer->start(msec.count());
|
timer->start(msec.count());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user