"x" and "y" are defined relatively to the parent. Thus you cannot reference other item's "x" and "y" values as they are in a different coordinate system. This is similar to:
Item {
id: i1
x: 10
Item {
id: i2
x: 10
}
}
Item {
id: i1
x: 10
Item {
id: i2
x: 10
}
}
To copy to clipboard, switch view to plain text mode
Item "i2" has an absolute x value set to 20 as it is translated by 10 relative to its parent. If instead you do:
Item {
id: i1
x: 10
Item {
id: i2
x: parent.x+10
}
}
Item {
id: i1
x: 10
Item {
id: i2
x: parent.x+10
}
}
To copy to clipboard, switch view to plain text mode
Then i2.x == 20 and thus the absolute value is 30 and not 20.
In your code the transformation origin should be set to:
origin.x: line.width/2;
origin.y: line.height/2;
origin.x: line.width/2;
origin.y: line.height/2;
To copy to clipboard, switch view to plain text mode
which is equivalent to setting transformOrigin to Item.Center (which is the default).
Bookmarks