Hello,
Is there a way to have:
QString function_name = foo;
call_user_func(function_name, 10);
with somewhere in the codes:
void foo(int);
This feature exists in php
Thanks!
Hello,
Is there a way to have:
QString function_name = foo;
call_user_func(function_name, 10);
with somewhere in the codes:
void foo(int);
This feature exists in php
Thanks!
You can use QScriptEngine::evaluate() to evaluate an invokable function by its name or you can use QMetaObject::invokeMethod() to invoke an invokable method by its name from C++ code directly. Invokable methods are ones that are either slots or have Q_INVOKABLE modifier. Apart from that, what you want is not possible in C++ because it is a compiled binary language as opposed to PHP which is an interpreted textual language.
Bookmarks