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 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.