import QtQuick 1.0
Rectangle {
id: container
width: 1500; height: 1000
Component.onCompleted: {
var component = Qt.createComponent("rectangle.qml");
// Define an array
var sim_data = new Array(3); // 10 rectangles for 3 secs
var t = 0;
for(var i = 0;i<3;i++)
sim_data[i] = new Array(10);
sim_data[0]= [0.000000,0.098023,0.192176,0.282582, 0.369357,0.452661,0.532547,0.609014,0.682063,0.751692,0.817902];
sim_data[1]= [10.000000,9.900498,9.801986, 9.704455,9.607893,9.512226,9.417414,9.323457,9.230357,9.138112,9.046724];
sim_data[2]= [0.000000,0.000493,0.001946,0.004321,0.007583,0.011704, 0.016680,0.022509,0.029193,0.036732];
var col = ["red","yellow","green","blue","black"];
// working
for(var t=0; t < 3; t++)
{
var y = 100 * t + 150;
console.log("At t = ", t);
for (var i=0; i<10; i++)
{
var object = component.createObject(container);
object.width = sim_data[t][i] + 100;
object.height = sim_data[t][i] + 100;
console.log("width = ", object.width);
console.log("height = " ,object.height);
object.x = 150 * i;
object.y = 100;
object.color = col[t];
}
}
}
}
import QtQuick 1.0
Rectangle {
id: container
width: 1500; height: 1000
Component.onCompleted: {
var component = Qt.createComponent("rectangle.qml");
// Define an array
var sim_data = new Array(3); // 10 rectangles for 3 secs
var t = 0;
for(var i = 0;i<3;i++)
sim_data[i] = new Array(10);
sim_data[0]= [0.000000,0.098023,0.192176,0.282582, 0.369357,0.452661,0.532547,0.609014,0.682063,0.751692,0.817902];
sim_data[1]= [10.000000,9.900498,9.801986, 9.704455,9.607893,9.512226,9.417414,9.323457,9.230357,9.138112,9.046724];
sim_data[2]= [0.000000,0.000493,0.001946,0.004321,0.007583,0.011704, 0.016680,0.022509,0.029193,0.036732];
var col = ["red","yellow","green","blue","black"];
// working
for(var t=0; t < 3; t++)
{
var y = 100 * t + 150;
console.log("At t = ", t);
for (var i=0; i<10; i++)
{
var object = component.createObject(container);
object.width = sim_data[t][i] + 100;
object.height = sim_data[t][i] + 100;
console.log("width = ", object.width);
console.log("height = " ,object.height);
object.x = 150 * i;
object.y = 100;
object.color = col[t];
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks