I'm trying to learn about QT script and I'm clearly not understanding something basic.
Consider the following code:

Qt Code:
  1. #include <iostream>
  2.  
  3. #include <QApplication>
  4. #include <QtScript>
  5. #include <QObject>
  6.  
  7. using namespace std;
  8.  
  9. class MyClass : public QObject
  10. {
  11. public:
  12. int x;
  13. };
  14.  
  15. int main(int argc, char* argv[])
  16. {
  17. QApplication app(argc, argv);
  18.  
  19. MyClass mc;
  20. mc.x = 0;
  21.  
  22. QScriptEngine eng;
  23. QScriptValue scriptClass = eng.newQObject(&mc);
  24. QScriptValue global = eng.globalObject();
  25. global.setProperty("myClass", scriptClass);
  26.  
  27. QScriptValue res = eng.evaluate("myClass.x == 0");
  28. if (res.isBoolean())
  29. {
  30. cout << "res is 0 = " << res.toBoolean() << endl;
  31. }
  32. else
  33. {
  34. cout << "res is not boolean!!!" << endl;
  35. }
  36. return 0;
  37. }
To copy to clipboard, switch view to plain text mode 

This prints "res is 0 = 0" when run. It seems that the script engine does know about myClass but the value of myClass.x is not set.
Can someone enlighten me?

Thanks,
Steve