Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Application Portrait and Landscape mode (Horizontal/Vertical rotation)



  • Hi,
    I would like to add option to rotate my application between Portait and Landscape mode. (Linux handheld device).
    I tried nesting Item inside main ApplicationWindow, with custom rotate flag swap width/height and set item rotation 0/90.
    Problem is - that lots of internal components rely on anchors and are placed in app corner. After above rotation, component from bottomLeft is now in bottomRight and is on side.
    I would like to avoid tedious process of exposing flag to all components and usage of condition expressions to decide how to place them.


  • Moderators

    @SebastianM
    The "default" provided QML components listen to Window.contentOrientation property - like Popups on the Overlay



  • Help me understand.
    Screen.orientation is OS information about current display orientation (if HW uses accelerometer or user manual change orientation).
    Window.contentOrientation applicaton changes to notify OS display server/windows manager how it describe it's own orientation.

    In both situation, if my App placed Rectangle in bottomLeft and device has been rotated. Rectangle will be rotated (lying on side) on and in new corner.
    Is is possible for app to treat anchors.top the same despite orientation change? I mean - in Vertical Top is this what Right was in Horizontal?

    I don't like idea to use rotation/orientation flag in all places where position is set. Or create two separate layouts changed with orientation.



  • Out of pure curiosity, what is your Linux device?, I'm using Sony Xperia 10ii with SailfishOS, screen orientation is more or less handled by the device. Perhaps they way orientation is done in Sailfish, could be applied to your device...?.



  • It's commercial project on EGLFS without built-in orientation. Yocto will handle system setup.
    For now I'm starting to getting used to idea of two separate layouts.


  • Moderators

    @SebastianM
    i think i dont understand your problem.

    I tried nesting Item inside main ApplicationWindow, with custom rotate flag swap width/height and set item rotation 0/90.

    when you do this, all anchors are also translated. means bottom-left of horizontal will also be bottom-left in vertical when the device is rotated.

    Problem is - that lots of internal components rely on anchors and are placed in app corner. After above rotation, component from bottomLeft is now in bottomRight and is on side.

    can you please show how you are placing those elements



  • I didn't add anchors.centerIn: parent in content Item (which is rotated and is changing size). In result, after rotation Item was placed in completely crazy place.



  • This post is deleted!

Log in to reply