Drawing to the left of x, y coordinates

I am currently working on Qt when I try to draw something (for ex Rectangle), giving its x, y coordinates & its width & height Qt starts to draw a rectangle starting from its x, y coordinates in the right direction to demonstrate what I'm talking about, see the following picture:

Rect1

and the following code:

Rectangle {
    id: rectangle1
    x: 257
    y: 221
    width: 50
    height: 50
    color: "#000000"
}

I would like to know if in any case I can start drawing to the left of the x, y coordinates, it's like drawing giving the width & height negative values. see the following image for illustration:

Rect2

I tried to draw, giving the width a negative value, it works fine in design mode, but when I launch or debug my application, the right-angled nick is not displayed, any ideas about this will be appreciated

+4
2

, QML. Scale :

Rectangle {
    id: rectangle1
    x: 257
    y: 221
    width: 50
    height: 50
    color: "#000000"

    transform: Scale { origin.x: 0; origin.y: 0; xScale: -1}
}

Scale . X (0, 0).

+4

50px :

Rectangle {
    id: rectangle1
    x: parent.width - 50 // rectangle start 50px from the left
    y: 221  // similar with y pos: parent.height - 50
    width: 50
    height: 50
    color: "#000000"
}

, .

0

Source: https://habr.com/ru/post/1570889/


All Articles