Exposing C++ list of objects to Scripting (QJSEngine)



  • Hello,

    I am trying to expose a list of C++ objects to Scripting. To keep it simple, lets say I want to have a list of files.

    desired Script code:
    @var filelist = getFileList()
    for(var onefile in filelist)
    {
    myPrintFunction(onefile.size)
    }
    @

    1) Is this possible (how?) and are there any examples around? I searched my head off but did not succeed.

    I have succeeded in exposing singular QFiles to script by wrapping them in a QObject based "MyFile"-class and brokering between MyFile and the real wrapped QFile through Q_INVOKABLE and Q_PROPERTY.

    2) Can this be done using the new QJSEngine?

    The second question is: is this possible via QJSEngine (not the old QtScript QScriptEngine engine but the new v8-based one that is used in QML, faster and guaranteed to stay around) - and is it a good idea to settle for QJSEngine in favor of QScriptEngine?


Log in to reply
 

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