yes loop.js is in the same directory
Loop.js has a fucntion which has the variant list as parameter.
Here i am using power cells defined by me as a element on which the loop is being called on.
Below is the code for loop.js
var PCell = new Array;
var i = 0;
var powerComponent = Qt.createComponent("PowerCell.qml");
function setPowerCells(pList)
{
PCell = pList;
for(i = 0; i < (PCell.length - 1);i+2)
{
PCell.iconValue = pList[i];
PCell.instrumentedStatus = pList[i+1];
}
}
var PCell = new Array;
var i = 0;
var powerComponent = Qt.createComponent("PowerCell.qml");
function setPowerCells(pList)
{
PCell = pList;
for(i = 0; i < (PCell.length - 1);i+2)
{
PCell.iconValue = pList[i];
PCell.instrumentedStatus = pList[i+1];
}
}
To copy to clipboard, switch view to plain text mode
This is the code for power cell to be called by js file
import Qt 4.7
Item {
id: button
signal clicked
property string iconValue
property string instrumentedStatus
signal name
property bool toggled: false
width: 133
height: 135
Image {
id:button_img
anchors.fill: button
anchors.margins: mouseArea.pressed
smooth: true
source: { if ("instrumented" == button.instrumentedStatus)
return "instrumentedButton.png"
else if ("non-instrumented" == button.instrumentedStatus)
return "nonInstrumentedButton.png"
}
Image {
x:37
y:40
width: 54
height: 56
id: instrumentIcon
source: button.iconValue
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
button.clicked()
}
}
}
import Qt 4.7
Item {
id: button
signal clicked
property string iconValue
property string instrumentedStatus
signal name
property bool toggled: false
width: 133
height: 135
Image {
id:button_img
anchors.fill: button
anchors.margins: mouseArea.pressed
smooth: true
source: { if ("instrumented" == button.instrumentedStatus)
return "instrumentedButton.png"
else if ("non-instrumented" == button.instrumentedStatus)
return "nonInstrumentedButton.png"
}
Image {
x:37
y:40
width: 54
height: 56
id: instrumentIcon
source: button.iconValue
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
button.clicked()
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks