Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Rotate coordinates of display?

Rotate coordinates of display?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 522 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    I have an app I would like to test in full screen with a resolution of 1920x1080. I would also like to test the orientation of the display as if the display is 1080x1920. I tried using the Page component to rotate (rotation: -90), but it does not swap the underlying coordinates of the Components inside of it. It just rotates all the components, but the top level component inside the Page still sees the area as 1920x1080. Is there a way to rotate the entire app such that the width and height get swapped as well?

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      I tried virtualizing the width and height and it sorta works:

      property int r_width: pagerot.rotation == 0 ? width : height
      property int r_height: pagerot.rotation == 0 ? height : width
      

      But the origin of where it starts drawing does not seem to be the corner where I would expect it to be. It would also cause the mouse to be wrong when testing. I am just going to rely on the operating system to rotate my screen for testing. This trying to trick qml to do it is folly.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • Shrinidhi UpadhyayaS Offline
        Shrinidhi UpadhyayaS Offline
        Shrinidhi Upadhyaya
        wrote on last edited by
        #3

        Hi @fcarney , just to add, i guess the simplest way you can do is to deploy a simple android app, with auto-rotate enabled on your phone. So when you rotate your phone the height and width get swapped.

        I just tried a sample app with 2 Rectangles inside a ColumnLayout and Rectangles consisting of a text which prints the Screen.height and Screen.width

        ColumnLayout {
            anchors.fill: parent
        
            Rectangle {
                Layout.fillHeight: true
                Layout.fillWidth: true
                color: "red"
        
                Text {
                    text: Screen.height
                    anchors.centerIn: parent
                }
            }
        
            Rectangle {
                Layout.fillHeight: true
                Layout.fillWidth: true
                color: "green"
        
                Text {
                    text: Screen.width
                    anchors.centerIn: parent
                }
            }
        }
        

        Portrait Mode:-
        0_1559197044024_ab817d6a-452d-4861-b1de-926b6193c362-image.png

        Landscape Mode:-
        0_1559197075947_9c5f9336-a4cf-4b28-ba7b-07b70c233691-image.png

        Here the red rectangle prints the height and green rectangle prints the width, so you can see from the above images when rotate your phone the height and the width get swapped.

        Shrinidhi Upadhyaya.
        Upvote the answer(s) that helped you to solve the issue.

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved