Script engine - porting from Qt5 to Qt6 issues
-
Hello everyone,
I am trying to port a program from Qt5 to Qt6, and I am encountering some issues with the scripting system. Currently, the program uses QScriptEngine and exposes both custom types and C++ standard types to the engine using qScriptRegisterMetaType.
I have switched to QJSEngine, and most functionalities are working fine. However, I am unable to expose my custom types since the qScriptRegisterMetaType method no longer exists.
I checked the documentation and found some forum posts discussing this issue, but there don’t seem to be any solutions.https://forum.qt.io/topic/143674/porting-from-qtscript-to-qjsengine-setscriptclass-and-toscriptvalue-and-fromscriptvalue-functions
https://forum.qt.io/topic/24368/custom-c-types-and-qjsengineIs there any alternative to qScriptRegisterMetaType, or a way to manually expose custom types?
Thanks,
Yuri -
Hi Yuri,
I'm one of the posters you mentioned above.
Sadly the solution I eventually went with was to use quickjs as our javascript engine which gives much more control over the java script environment and allowed me to create/control the plumbing around using c++ types within the javascript environment.Sorry i dont have any other help for you.