QJSEngine and C++ classes instanciated from JavaScript

  • Hello,

    with the old QtScript it was possible to define a JavaScript class which is based on a C++ class.

    The code for this purpose on C++ was
    QScriptValue ctor = engine->newFunction(constructor);
    QScriptValue myScriptClass = engine->newQMetaObject(&QObject::staticMetaObject, ctor);
    engine.globalObject().setProperty("MyClass", myScriptClass);

    Then it was possible to write in JavaScript
    @var x = new MyClass();@

    How can this be achieved with the new QJSEngine?

    Best regards,

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.