Search code examples
c++qt4scriptingcomplex-numbersqtscript

How to use c++ std complex numbers in QtScript


I try to find out how to use complex numbers in QtScripts such that slots defined with complex arguments can be called from a QtScript. Also basic algebra (+,-,exp, ... ) of complex-numbers should be accessible to the user from the script.

Just for illustration want I want to call is:

#include<complex>
typedef complex<double> Complex;

class MyCppClass : public QObject
{
Q_OBJECT
public:
  ...
public slots:
void mySignal(Complex rCValue); !! <<== should be callable from QtScript
  ...
}

Any ideas? Thx!


Solution

  • I think you must implement complex algebra in QtScript (something like http://examples.oreilly.com/9781565923928/text/8-6.txt) and then modify mySignal to accept an object like this.