I've have been investigating QtScript and I wrote a little test program which worked. The expression first evaluates false and the second time true.

Qt Code:
  1. #include <iostream>
  2.  
  3. #include <QApplication>
  4. #include <QtScript>
  5. #include <QObject>
  6. #include <QWidget>
  7.  
  8.  
  9. class MyClass : public QObject
  10. {
  11. Q_PROPERTY(bool x)
  12. Q_PROPERTY(int y)
  13. };
  14.  
  15. using namespace std;
  16.  
  17. int main(int argc, char* argv[])
  18. {
  19. QApplication app(argc, argv);
  20.  
  21. MyClass mc;
  22.  
  23. QScriptEngine eng;
  24. QScriptValue scriptClass = eng.newQObject(&mc);
  25. QScriptValue global = eng.globalObject();
  26. global.setProperty("myClass", scriptClass);
  27.  
  28. const QString expr = "myClass.x == true && myClass.y == 2";
  29.  
  30. mc.setProperty("x", true);
  31. mc.setProperty("y", 0);
  32. QScriptValue res = eng.evaluate(expr);
  33. cout << "result = " << res.toBoolean() << endl;
  34.  
  35. mc.setProperty("y", 2);
  36. res = eng.evaluate(expr);
  37. cout << "result = " << res.toBoolean() << endl;
  38.  
  39. return 0;
  40. }
To copy to clipboard, switch view to plain text mode 
Then it occurred to me that perhaps it should not have compiled. The documentation for Q_PROPERTY says that
The property name and type and the READ function are required
but I didn't have a read function defined so how did that work?

The next thing I wanted to do was to add a slot so I added Q_OBJECT above the Q_PROPERTY line, ran gmake clean, make-qt4 and gmake. I got these linker errors:
main.o: In function `MyClass': undefined reference to `vtable for MyClass'
main.o: In function `~MyClass': undefined reference to `vtable for MyClass'

It's referring to a constructor and destructor I don't have so I tried adding my own empty ones but that didn't help.
Next I though that perhaps I have to define at least one slot or signal so I added one but that didn't help.

Here is where it gets a little weird, at least to me. I took the class definition and put it in a .h file without changing anything apart from adding the #include of course, re-ran everything and now it links OK and I get warnings about the Q_PROPERTY macros not having a read function and that the properties will be invalid. So I added the read functions to the Q_PROPERTY lines, defined the functions and added some private variables.

Cool! now everyting compiles and links without errors and warnings.
Just one problem - the evaluation of the expression is now false in both cases!!!