views:

24

answers:

1

I'm trying to convert a QVariantMap to Qt Script object. If I understood correctly it should go something like this:

QScriptEngine* engine = new QScriptEngine();
QVariantMap* test = new QVariantMap();
test.insert("testkey", QString("testvalue"));
QScriptValue testqs = engine->toScriptValue(test);
QString value = testqs.property("testkey").toString();

I'm not sure if that is the right way to event try to ask for the value from the ScriptValue. But the root problem is that the Script object I get, doesn't seem the have any of the properties that were in the map to begin with.

So, what am I missing?

+1  A: 

Ok, so I figured out my problem. If I would have read the specs correctly I would have noticed that the toScriptValue() method won't take a pointer. So the fix was:

QScriptValue testqs = engine->toScriptValue(*test);