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
Rectangle {
id: circle
x: ...
y: ...
radius: {
//linkscoretoanalysis.source = "Letter.qml";
Global.j++
Global.scoretoanalysisXarray[Global.i] = circle.x+8;
}
MouseArea {
Rectangle {
id: circle
x: ...
y: ...
radius: {
//linkscoretoanalysis.source = "Letter.qml";
Global.j++
Global.scoretoanalysisXarray[Global.i] = circle.x+8;
}
MouseArea {
To copy to clipboard, switch view to plain text mode
Letter.qml
Text {
id: letter
x: ...
y: ...
text: {
if(Global.i > 0){
Global.i++
}
...
}
MouseArea {
onClicked: {
mytimer.running = true;
Global.timerbool = true;
}
Timer {
id: mytimer
interval: 1
repeat: true
running: true
onTriggered: {
letter.x = Global.scoretoanalysisXarray[Global.i];
if(Global.i < Global.j){
Global.i=1
Global.j=1
console.log("if1");
}
if(Global.timerbool == false){
mytimer.running = false;
}
}
}
Text {
id: letter
x: ...
y: ...
text: {
if(Global.i > 0){
Global.i++
}
...
}
MouseArea {
onClicked: {
mytimer.running = true;
Global.timerbool = true;
}
Timer {
id: mytimer
interval: 1
repeat: true
running: true
onTriggered: {
letter.x = Global.scoretoanalysisXarray[Global.i];
if(Global.i < Global.j){
Global.i=1
Global.j=1
console.log("if1");
}
if(Global.timerbool == false){
mytimer.running = false;
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks