I have a two files (Circle.qml and Letter.qml). On click of the mousearea a circle is placed along with the text of letter, because the Circle.qml refers to the Letter.qml file. Now I want to move the letter in x-direction on drag of the Circle in x-direction. I have tried this with a timer using beneath code, but you can click different circles with their own letters; each of the circle/letter combinations have to be movable independently. Now sometimes the link between circle and letter is not made, and sometimes the same circle is linked with multiple letters causing all these letters of other circles to be moved in x-direction. My questions:
- how can I get the program working as I described?
- do I follow the right approach (for example using a timer)?
- if not, which approach should I follow?


Circle.qml
Qt Code:
  1. Rectangle {
  2. id: circle
  3. x: ...
  4. y: ...
  5. radius: {
  6. //linkscoretoanalysis.source = "Letter.qml";
  7. Global.j++
  8. Global.scoretoanalysisXarray[Global.i] = circle.x+8;
  9. }
  10. MouseArea {
To copy to clipboard, switch view to plain text mode 

Letter.qml
Qt Code:
  1. Text {
  2. id: letter
  3. x: ...
  4. y: ...
  5. text: {
  6. if(Global.i > 0){
  7. Global.i++
  8. }
  9. ...
  10. }
  11. MouseArea {
  12. onClicked: {
  13. mytimer.running = true;
  14. Global.timerbool = true;
  15. }
  16. Timer {
  17. id: mytimer
  18. interval: 1
  19. repeat: true
  20. running: true
  21. onTriggered: {
  22. letter.x = Global.scoretoanalysisXarray[Global.i];
  23.  
  24. if(Global.i < Global.j){
  25. Global.i=1
  26. Global.j=1
  27. console.log("if1");
  28. }
  29.  
  30. if(Global.timerbool == false){
  31. mytimer.running = false;
  32. }
  33. }
  34. }
To copy to clipboard, switch view to plain text mode