This is the initial code:

Qt Code:
  1. import QtQuick 2.0
  2.  
  3. Rectangle
  4. {
  5. id: container
  6. height: 300
  7. width: 300
  8.  
  9. WindowA
  10. {
  11. x:0
  12. id: windowAId
  13. color: "green"
  14. }
  15.  
  16. WindowB
  17. {
  18. id: windowBId
  19. anchors.top: windowAId.bottom
  20. anchors.topMargin: 10
  21. color: "black"
  22. }
  23.  
  24. signal completed
  25.  
  26. ListModel {
  27. id: fooModel
  28. ListElement { data: "red" }
  29. }
  30.  
  31. Component.onCompleted: {
  32. console.log("Rect Completed!")
  33. container.completed()
  34. }
  35.  
  36. Component
  37. {
  38. id: delg
  39. Item
  40. {
  41. Rectangle
  42. {
  43. id: moveMe
  44. height: 10; width: 10
  45. border.width: 1; border.color: "black"
  46. state: model.data
  47. color: state
  48.  
  49. MouseArea {
  50. anchors.fill: parent
  51. onClicked: {
  52. moveMe.state = (moveMe.state == "red" ? "blue" : "red")
  53. }
  54. }
  55.  
  56. states: [
  57. State {
  58. name: 'red'
  59. ParentChange { target: moveMe; parent: windowAId; x: windowAId.x }
  60. },
  61. State {
  62. name: 'blue'
  63. ParentChange { target: moveMe; parent: windowBId; x: windowBId.x }
  64. }
  65. ]
  66. }
  67. }
  68. }
  69.  
  70. Repeater {
  71. id: repeat
  72. model: fooModel
  73. delegate: delg
  74. }
  75. }
To copy to clipboard, switch view to plain text mode 

It results in this:

2014-01-27-131146_1280x1024_scrot.png



How should I refer to WindowA and WindowB from this QML file if they are placed in a different QML file? (without using a loader)