I want set a property like xxx.xxx.xxx in qt scirpt ,so I write code like these:

Qt Code:
  1. QScriptEngine engine;
  2. QScriptValue o = engine.globalObject();
  3. QScriptValue oo;
  4. QScriptValue o1;
  5.  
  6. o1 = o.property("org");
  7. if (!o1.isValid()) {
  8. o1 = engine.newObject();
  9. o.setProperty("org", o1);
  10. }
  11.  
  12. o1= o.property("org.math");
  13. if (!o1.isValid()) {
  14. o1 = engine.newObject();
  15. o.setProperty("math", o1);
  16. }
  17.  
  18. engine.evaluate("org.sum = function Math_sum(a){ return 123456; }");
  19. engine.evaluate("org.math.sum = function Math_sum(a){ return 654321; }");
  20. engine.evaluate("var r = org.sum(12); print(r); ");
  21. engine.evaluate("var r1 = org.math.sum(12); print(r1); ");
To copy to clipboard, switch view to plain text mode 

output is: 123456
so the org.math.sum is invalid.

I have try this way too:
Qt Code:
  1. QScriptValue o = engine.globalObject();
  2. QScriptValue oo;
  3. QScriptValue o1;
  4.  
  5. o1 = o.property("org");
  6. if (!o1.isValid()) {
  7. o1 = engine.newObject();
  8. o.setProperty("org", o1);
  9. }
  10.  
  11. QScriptValue o2;
  12. o2= o1.property("math");
  13. if (!o2.isValid()) {
  14. o2 = engine.newObject();
  15. o.setProperty("math", o2);
  16. }
To copy to clipboard, switch view to plain text mode 

but the output still is 12345.

If i want excute function org.math.sum(), how should I set the property.