Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.3.0
-
-
b297e8fccf (qt/qtdeclarative/dev) b297e8fccf (qt/tqtc-qtdeclarative/dev)
Description
According to these docs: https://doc.qt.io/qt-6/qjsengine.html
It is supposed to be possible to register virtual JavaScript modules that are not backed by files using QJSEngine::registerModule.
I.e something like this:
QJSValue name("Qt6"); QJSValue obj = myEngine.newObject(); obj.setProperty("name", name); myEngine.registerModule("info", obj);
import { name } from "info"; export function getName() { return name; }
However these modules do not appear to be accessible at all from either QML or more importantly javascript files imported from QML files.
Attached is a simple test project that I would have expected to work given the above docs.