I'm having trouble reading a javascript variable from QML. I know this seems easy, but this is a particular case :
I'm using canvas3D for generating lots of 3D Spheres and, as the instenciation is really long, I want to display a progress bar.
To do that, I've done this :
import "test6.js" as GLCode
Item {
id: mainview
width: 1280
height: 768
visible: true
// THE PROGRESS BAR
ProgressBar {
id : progressBar
anchors.centerIn: parent
value: canvas3d.progress
z:1
}
//THE CANVAS3D (WebGL)
Canvas3D {
id: canvas3d
anchors.fill: parent
focus: true
property double progress:0 //MY VARIABLE I WANT TO UPDATE FROM test6.js
property var list : []
// Emitted when one time initializations should happen
onInitializeGL: {
GLCode.initializeGL(canvas3d);
}
I have a property name progress in my canvas3d which I'm trying to modify from the test6.js script
In the initializeGL(canvas3d) function I'm updating the value of progress each time I add a sphere :
for ( i = 0; i < spheresNum; i ++ ) {
var x = list[i][0];
var y = list[i][1];
var z = list[i][2];
drawSphere(x,y,z,i);
canvas3d.progress = i/spheresNum*100;
}
Now, the problem is that I get the updated value of progress only when initializeGL() ends. Right now it's like :
Progress Bar to 0%
(Waiting for all the sphere to be instanciated)
(initializeGL() ends)
Progress Bar to 100%
Which is useless. I would prefer having the bar moving each time a sphere is created.
Do you know how can I do that ?