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
Qt Code:
  1. var PCell = new Array;
  2. var i = 0;
  3. var powerComponent = Qt.createComponent("PowerCell.qml");
  4.  
  5. function setPowerCells(pList)
  6. {
  7. PCell = pList;
  8. for(i = 0; i < (PCell.length - 1);i+2)
  9. {
  10. PCell.iconValue = pList[i];
  11. PCell.instrumentedStatus = pList[i+1];
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 


This is the code for power cell to be called by js file

Qt Code:
  1. import Qt 4.7
  2.  
  3. Item {
  4. id: button
  5. signal clicked
  6. property string iconValue
  7. property string instrumentedStatus
  8. signal name
  9. property bool toggled: false
  10. width: 133
  11. height: 135
  12. Image {
  13. id:button_img
  14. anchors.fill: button
  15. anchors.margins: mouseArea.pressed
  16. smooth: true
  17. source: { if ("instrumented" == button.instrumentedStatus)
  18. return "instrumentedButton.png"
  19. else if ("non-instrumented" == button.instrumentedStatus)
  20. return "nonInstrumentedButton.png"
  21. }
  22.  
  23. Image {
  24. x:37
  25. y:40
  26. width: 54
  27. height: 56
  28. id: instrumentIcon
  29. source: button.iconValue
  30.  
  31. }
  32.  
  33. }
  34.  
  35. MouseArea {
  36. id: mouseArea
  37. anchors.fill: parent
  38. onClicked: {
  39. button.clicked()
  40. }
  41. }
  42. }
To copy to clipboard, switch view to plain text mode