Search code examples
javascriptc++qt4qtscriptchaiscript

Is it possible to use custom c++ classes with overloaded operators in QtScript?


Does anyone know if it is possible to have a C++ class with overloaded operators such as +,-,* and declare it somehow (this is where the magic happens) to a QtScriptEngine such that js-expressions like "a+b" are evaluated as they would be on the C++ side?


Solution

  • It seems to be impossible. At least that is what I received as an answer in the #qt-labs IRC. However, I think I found a viable alternative: ChaiScript. It embeds itself wonderfully into C++, plays well with Qt and allows for the overloading of operators, and even better the direct use of any(?) C++ data type.