Important: Please read the Qt Code of Conduct -

LayoutDirection weirdly affects the XY coordinates

  • Hi,

    I used setLayoutDirection(Qt::RightToLeft) to my application. Some widgets change direction while other doesn't.
    I noticed that the XY Coordinate begins always from top left whatever the direction is, and wrongly affect my application. That is weird in my point of view.
    I created some projects with JavaFX. With LTR mode, the XY Coordinate starts from top left corner, while with RTL mode it starts from top right corner. So, that's logic.

    Is there a way to auto mirror all widgets, or at least reverse the XY system to start from top right.

    This images can explain what i mean:

    LeftToRight (Good result)
    Frame - LTR Good.png

    RighToLeft (Failed result)
    Frame - RTL Result.png

    RighToLeft (Expected result)
    Frame - RTL Expected.png


  • Lifetime Qt Champion

    How do you place your labels? When there is a spacer after '1' and all is in a proper layout then the mirroring works as expected. No need to change to coordinate system though.

  • Moderators

    The RTL mode does not change coordinate system. It would not be desirable for things like images, text or painting in general. What it does is change the order of elements in layouts. To get the result you want you would have a horizontal layout 100% wide with a spacer item as the last element. RTL layout would then reverse the order of elements in it and put the spacer on the left side.

  • @Chris-Kawa

    I expected that the RTL mode reverse also coordinate frame.
    There is no spacer item in my Hboxlayout.
    I will try your advices.

Log in to reply