diff --git a/libs/piqt/piqt_macros.h b/libs/piqt/piqt_macros.h index d9f59a7..86d623f 100644 --- a/libs/piqt/piqt_macros.h +++ b/libs/piqt/piqt_macros.h @@ -44,6 +44,20 @@ 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 +void qCallQueued(O * o, F f, Args... args) { + QMetaObject::invokeMethod( + o, + [o, f, args...]() { (o->*f)(args...); }, + Qt::QueuedConnection); +} + + namespace PIQt { template