Fix orientation of mobile application



  • I want to lock the orientation of the mobile application ( android and ios ) that i'm developing in portrait mode for some of the pages that i'm showing even if the Screen Rotation option of the device is enabled. In other words - I want to rotate the device and the application to stay unchanged. I'm talking about qml application. I looked at the OrientationSensor from QtSensors but I couldn't find the right way to use it.

    Is what i'm trying to do possible? And how can I do it?


  • Moderators

    Hi,
    I have not done for ios app but for Android application you need to modify the AndriodManifest.xml and put this in the activity tag,
    @
    android:screenOrientation="landscape" //or portrait
    @
    also set the permission
    @
    <uses-permission android:name="android.permission.SET_ORIENTATION"/>
    @



  • If I do this it will affect the whole application, right? I want to affect only some pages from it.


  • Moderators

    Right. Well then i guess you need to set the orientation from the java api's.
    May be Qt's Android extras will provide an easier way to do it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.