Important: Please read the Qt Code of Conduct -

QScriptValue of array nth element

  • Hi everybody,

    I have big trouble getting the nth element of a QScriptValue array.

    let's suppose we have a JavaScript array:

    var a = [ o1, o2, o3 ];

    Where o1..o3 are objects of arbitrary type.

    Now I get the QScriptValue for this array:

    QScriptValue v ="a");

    Now, how do I retrieve (for example) object o2 given v ?

    If a were an object, I could do a "", but a is an array and I'm stuck here ...

  • Found it:

    QScriptValue o2 ="1");

    because array indexes in JS are simply properties. The only thing is that you cannot write

    a.1;  // WRONG

    you must write




Log in to reply