[Development] Question about QtDeclarative Internals

Alex Shaw alex.shaw.as at gmail.com
Wed Apr 21 22:06:12 CEST 2021

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
I just thought this might be the most straightforward.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20210421/1f3ec346/attachment.html>

More information about the Development mailing list