Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Set orientation on iOS at runtime
Qt 6.11 is out! See what's new in the release blog

Set orientation on iOS at runtime

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 529 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.
  • P Offline
    P Offline
    peter-70
    wrote on last edited by
    #1

    I have an app with the following settings in the plist file:

       <key>UISupportedInterfaceOrientations</key>
       <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
       </array>
    

    They are the right settings, we need in our project.

    But I have one and only part as qml-view with a camera (for a barcode-scanner).
    These should be shown in all orientations, but at least landscape-orientation (left and right).

    I try to set this at runtime with a call from my c++ code:

    void MobileScreenOrientation::SetOrientation()
    {
    //    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
    //    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
    
        [[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft) forKey:@"orientation"];
        [UINavigationController attemptRotationToDeviceOrientation];
    }
    

    but it it doesn't work. The orientation in my qml is still portrait.
    Can you help me, how can I set the landscape orientation on iOS at runtime, quasi manually?

    Thanks!

    1 Reply Last reply
    0

    • Login

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