0

There is some platform with use of QtScript as the JavaScript interpreter for the description of logic of the application.

Example of a script on JS

var f=new File('/var/www/test1');
f.write('123\n');
f.CopyTo('/var/www/test2');

Object of File is described as

class File : public QObject, QScriptable  {
Q_OBJECT
 .. .
}

and such objects more than 10 it is described in a platform, a lot of logic is put in their constructor / destructor, there is Q_INVOKABLE methods which are called in a JS code.

Question: whether it is possible to transfer all this to QJSEngine having saved syntax of a JS code (it it is already much written)?

looked for responses to stackoverflow

Dynamic c++ object in QJSEngine

suggest to do through factory, but it will strongly worsen readability of a JS code and it should be rewritten

Community
  • 1
  • 1
  • What about `QJSEngine::newQMetaObject()` ? http://doc.qt.io/qt-5/qjsengine.html#newQMetaObject – Benjamin T Jan 26 '17 at 16:46
  • I do not quite understand what you meant – alexander_8901 Jan 27 '17 at 08:22
  • It seems your problem is about the way to create C++ objects from js. The `newQMetaobject` methods seems to give you the possibility to register a QObject derived class to the js engine and give you the possibility to create instances of it. At least that's how I understand the documentation. – Benjamin T Jan 27 '17 at 08:32

0 Answers0