Dynamc Call for QMetaObject::invokeMethod
-
i want to call Funtions through this function with arguments inside a for giving it index of the forloop as argument
i tried but i couldnt it took e long time
i want to ask about how to use
for (index)
QMetaObject::invokeMethod(object name,function,index)
how could i do that -
The documentation shows how to pass arguments to invokeMethod - or what do you want to achieve?
-
@Christian-Ehrlicher i have tried it
i have enum
and for loop
inside the for loop i want to call QMetaObject::invokeMethod with enum member as function
with index of the loop a argument -
So did you actually read my link? There is an example on how to call invokeMethod with parameters:
QString retVal; QMetaObject::invokeMethod(obj, "compute", Qt::DirectConnection, Q_RETURN_ARG(QString, retVal), Q_ARG(QString, "sqrt"), Q_ARG(int, 42), Q_ARG(double, 9.7));
-
@ThenewQtDev
You said you tried,
can you show is, us what you tried? -
@ThenewQtDev said in Dynamc Call for QMetaObject::invokeMethod:
PresentState
Is incorrect it‘s supposed to be a string or a functionpointer
-
@ThenewQtDev
Than I‘m afraid you have to share a bit more code 😉 -
@ThenewQtDev
Well that‘s not unexpexted
it‘s expecting a char * not a QString.
Change your variable accordingly and it should work