A
A
Alexander2017-04-26 15:08:38
Qt
Alexander, 2017-04-26 15:08:38

How to migrate from QtScript to QJSEngine?

I've been using Qt for a long time, I like everything cool, with the release of QJSEngine, QtSctipt was marked as obsolete,
but I still can't transfer some functionality to QtScript.
There is some platform using QtScript as a JavaScript interpreter to describe application logic.
JS script example

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

The File object is described as
class File: public QObject, QScriptable {
Q_OBJECT
….
}

and there are more than 20 such objects described in the platform, a lot of logic is embedded in their constructor / destructor, there are Q_INVOKABLE methods that are called in JS.
The question is: how to transfer all this to QJSEngine while preserving the syntax of the JS code (it has already been written a lot)?
I was looking for answers on stackoverflow
Dynamic creation of c ++ objects in QJSEngine
Transition from QtScript to QML/QJSEngine
Dynamic c ++ object in QJSEngine
It is suggested to do it through the factory, but this will greatly impair the readability of the JS code and it will have to be rewritten.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question