Hi,
In my program i have to access and change the value of a variable from different QML-files and from Javascript-files.
I'm using a JavaScript file to store the value:
//GlobalData.js
.pragma library
var myValue = 42;
//GlobalData.js
.pragma library
var myValue = 42;
To copy to clipboard, switch view to plain text mode
In my QML-files i use the variable like this:
//example.qml
import "GlobalData.js" as GData
...
//example.qml
import "GlobalData.js" as GData
...
To copy to clipboard, switch view to plain text mode
Everything works fine. There is only one instance of the GlobalData.js file and every QML-document can read and write myValue.
But now, i included GlobalData.js into a JavaScript like this:
//myJavaScript.js
Qt.include("GlobalData.js");
console.log(myValue);
//myJavaScript.js
Qt.include("GlobalData.js");
console.log(myValue);
To copy to clipboard, switch view to plain text mode
The problem is, that myJavaScript.js seems to create its own instance of GlobalData.js, so that if I modify myValue in a QML-Document, it's not changing in myJavaScript.js.
Is there any possibility to let myJavaScript access the same instance of GlobalData.js as the QML-Documents do, instead of creating its own one?
Thank You for your help
Bookmarks