Hello Fabian,

Thanks for replying.

The QJSValue represents any basic JS type that could be exported from a
regular module.
For example:
export const MAGIC = 6;
export default {
  name: "Qt6",
  version: "6.1.3"
}

In C++:
QJSValue magic(6);
QJSValue name("Qt6");
QJSValue version("6.1.3");
QJSValue obj = myEngine.newObject();
obj.setProperty("name", name);
obj.setProperty("version", version);
myEngine.registerModule("magic", magic);
myEngine.registerModule("qt_info", obj);

Then in JS:
import MAGIC from "magic";
import { version } from "qt_info";

Basically, it's like CreateSyntheticModule from V8.
I think something like this could be useful for applications using JS as a
scripting language.

There might be other ways to do what I need than converting QJSValue to an
ExecutableCompilationUnit;
I just thought this might be the most straightforward.

Thanks,
Alex
_______________________________________________
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to