lader1
1
Hi there and thx for reading and answering this post.
I just declare a basic variable like
var x = 2
in a .mjs file. ( Javascript module file)
then I import the .mjs file in my C++ application with
importModule("mylib.mjs");
So far so good, but before qt 4.14, I was able to retrieve x with e.g.
var y = module.x
But now, I can’t get x anymore.
Have an idea ??
Thx for answering
I don’t work with Qt and I find odd that a simple var declaration can be accessed from the outside. Anyways, I looked up and found this syntax:
import * as mylib from "mylib.mjs";
mylib.x
lader1
4
No, I won’t directly import from JS script, but from my C++ app with importModule()
The syntax above is for QML: https://doc-snapshots.qt.io/qt5-dev/qtqml-javascript-imports.html
If you’re not using QML, try using the export keyword before the var declaration, which is the proper usage anyways. See: https://doc-snapshots.qt.io/qt5-5.12/qjsengine.html
lader1
6
Added export to my var declaration but it doesn’t change anything, sorry…
lader1
7
I also upgraded to Qt 14.1, but no way with or without the export keyword