c++qtfunction-pointerspointer-to-memberqtscript

How do I cast class method to QScriptEngine::FunctionSignature


I want to pass this method:

QScriptValue ScriptProcessContext::construct(QScriptContext * ctx, QScriptEngine *)
{
    return this->newInstance();
}

to QScriptEngine::newFunction. I tried the following options:

So how to write it correctly?


Solution

  • You try to pass a memberfunction. That is not supported. Use a free function or a static method.

    Note that in both cases, you won't have a this pointer. You need to write the function in a way that it doesn't need an object.