Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

New C++-JS-Types with constructor for QML's QtScript



  • Hi,

    for QScriptEngines it is possible to create C++ functions that you can use as constructors in javascript using @QScriptEngine::newFunction ( FunctionSignature fun, const QScriptValue & prototype, int length = 0 )@
    and then you can call
    @ var myObj = new CPPConstructor() @

    Is it possible to do the same for QML?
    QDeclarativeEngine just allows you to create new QML types, but I don't see how to add new javascript types.

    Cheers,

    Manuel



  • Hi,

    Unfortunately this isn't currently possible. http://bugreports.qt.nokia.com/browse/QTBUG-11942 is probably the most relevant suggestion to track in regards to this.

    Regards,
    Michael


Log in to reply