I want to make a math editor using qtscript It will support the calculated array in the script. Like array1 + array2 = array3 ({1,2,3} + {3,4,5} = {4,6,8}); Maybe I need an override operator, I consult the example of CubitArere, and I override the operator +, but when I execute in the script, no one can be called, any doubles me Have some suggestions?
byteearray .h class bytereclass: public QObject, public QScriptClass {public: QByteArray and operator + (int n); } Main.cpp int main (int argc, char ** argv) {queer application application (argc, argv); QScriptEngineEng; Bitereurels * Boxes = new byterels (& amp; eng); Eng.globalObject (). SetProperty ("byte", baClass-> constructor ()); Eng.evaluate ("BA = new byte (4))" eng.evaluate ("BA + 2;"); // It will not bring operaire operator + bytereclass * b = new bytereclass (& amp; eng); Int n = 3; * BA + N; // But this override operator can apply to +} If this can not happen, then perhaps the only way is to convert all operators to a custom function.
As far as I know that operators can not be overloaded in QtScript, because it's normal Not allowed in Javascript (see, for example and this).
Now in your case you have the option to go with the Add, Mult, ... functions or leave it for some less constrained scripting language
Comments
Post a Comment