First: Qt 4.7
I would like to access a QVector<double>
inside a script, which is the return value of an object member function. I.e. I've passed the object to the script, and it has property set and get functions which have QVector<double>
as arguments/return values respectively.
I have done the following:
in its own header:
Q_DECLARE_METATYPE(QVector<double>)
when I set the engine up:
_engine = new QScriptEngine()
qScriptRegisterSequenceMetaType< QVector<double> >(_engine);
My object (CalcDataVector
) has the following public slots (_value
is a protected member):
QVector<double> value() { return _value; }
void value(QVector<double> data) { _value = data; }
And I send the object to the script engine like this:
CalcDataVector *v = new CalcDataVector(); // paraphrasing..
QObject *object = v;
QScriptValue value = engine()->newQObject(object);
engine()->globalObject().setProperty("in", value);
I want to access the vector in v inside the script :
var test = in.value()
Which, as I am new to qscript, may have a blindingly obvious syntax error. Please enlighten me!
I get the syntax error:
Syntax Error: Parse Error.
I can manipulate the object I'm sending in other ways, so I know it's there.
edit: I also send an output variable of the same type as the input. I can do the following:
var test = [ 100, 200, 300 ]
out.value(test)
but not
var test = [ 100, 200, 300 ]
in.value(test)