Using a member function with QScriptEngine::newFunction

Posted by Rohan Prabhu on Stack Overflow See other posts from Stack Overflow or by Rohan Prabhu
Published on 2010-05-29T16:38:39Z Indexed on 2010/05/29 16:42 UTC
Read the original article Hit count: 447

Filed under:
|
|

Hey all, Let's take the case of a simple class:

QScriptEngine engine;

class MyClass {
public:
    QScriptValue foo(QScriptContext*, QScriptEngine*);
    MyClass();
};

QScriptValue MyClass:foo(QScriptContext* context, QScriptEngine* eng) {
    //something
}

MyClass::MyClass() {
    QScriptValue self = engine.newFunction(this->foo, 0);
    ....
}

The above function gives me an error: no matching function for call to ‘QScriptEngine::newFunction(<unresolved overloaded function type>, int)’

I have tried using engine.newFunction(reinterpret_cast<FunctionSignature>(foo), 0); but this gives me an error which basically says that the compiler is not aware of a keyword called 'FunctionSignature'.

Any help is appreciated. Thanks a lot.

Regards, rohan

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt