Hi!
I am trying to manually position a rectangle within another rectangle. I have the following code:
Rectangle {
id: area
x: parent.width - area.width / 2
height: 30
color: "red"
width: 400
Rectangle {
id: hitArea
x: parent.x
y: parent.y
height: 30
width: 30
color: "blue"
}
}
The problem is the rectangle hitArea’s x-co-ordinate is actually calculated as being parent.width – (area.width / 2) but is instead calculated as being parent.width. To make this work I need to set the hitArea‘s x property to be parent.x + area.width / 2.
While this works it doesn’t look very elegant. Why is the hitArea not taking its x property as I expect it would (i.e after the parent’s x property has been evaluated)?
BTW I don’t want to use anchors here because ultimately I want to be able to position the hit area randomly along width of the area according to some parameters.