PDA

View Full Version : QtScript: Iterate over all custom QScriptValues



android_
22nd October 2010, 10:05
Hello,
again i have searched the forums and the internet, but didn't find a satisfying answer to my problem.

I'm programming a system in which the user is able to add own Objects, which are evaluated by a QScriptEngine.
An example code which could be created is this:

my_parameter = new Object();
my_parameter.name = "My new Parameter";
my_parameter.value = "10";
my_parameter.unit = "km";

Now the problem: If the user has created several of this parameters I need to track them to read all relevant properties.
I intended to do this with QScriptValueIterator, in which i would iterate over all values and if they have a specially-named parameter which they all share i know this is one of the objects i want.
I was expecting custom objects to be properties of the QScriptEngines globalObject(), but it seems that is not the case.
Do you know a way to iterate over all properties which were created so i can sort out the ones which i need?

If you know a documentation where i can find the answer myself i'm perfectly happy, but the short QScriptEngine description was not of much help.

android_
25th October 2010, 11:20
Solved the problem by creating a new Object as a property of the globalObject() onto which all user-created parameters are put.