move qCallQueued

This commit is contained in:
2024-10-14 18:42:29 +03:00
parent 744d689eee
commit 6153c1d8dd
2 changed files with 14 additions and 14 deletions

View File

@@ -44,20 +44,6 @@
PIQt::qpiConnect(src, &decltype(PIQt::removePtr(src))::sig, tgt, &(tgt)->__stat_eh_##handler##__);
/// much more compact and easy to use alternative to QMetaObject::invokeMethod(... , Qt::QueuedConnection)
/// examples:
/// qCallQueued(this, &MyClass::myFunc);
/// qCallQueued(this, &MyClass::myFuncWithInt, 0xFF);
/// qCallQueued(this, &MyClass::myFuncWithIntAndString, 0xAB, "string");
template<typename O, typename F, typename... Args>
void qCallQueued(O * o, F f, Args... args) {
QMetaObject::invokeMethod(
o,
[o, f, args...]() { (o->*f)(args...); },
Qt::QueuedConnection);
}
namespace PIQt {
template<typename T>

View File

@@ -340,4 +340,18 @@ T qDeserialize(const QByteArray & data, int version = -1) {
}
/// much more compact and easy to use alternative to QMetaObject::invokeMethod(... , Qt::QueuedConnection)
/// examples:
/// qCallQueued(this, &MyClass::myFunc);
/// qCallQueued(this, &MyClass::myFuncWithInt, 0xFF);
/// qCallQueued(this, &MyClass::myFuncWithIntAndString, 0xAB, "string");
template<typename O, typename F, typename... Args>
void qCallQueued(O * o, F f, Args... args) {
QMetaObject::invokeMethod(
o,
[o, f, args...]() { (o->*f)(args...); },
Qt::QueuedConnection);
}
#endif // QAD_TYPES_H