Important: Please read the Qt Code of Conduct -

Deactivate then reactivate the orientation change

  • Hi !

    I would like my app to be in portrait mode while loading on Android and, once loaded, to be able to choose the orientation by rotating the mobile...

    How do I do this?


  • is it possible to freeze the orientation of the mobile during a phase of the execution of an application ?

    Thanks !

  • I was finally able to solve my problem by using this function:

    void Basique::setScreenOrientation(int orientation)
        QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
        if ( activity.isValid() )
                    ("setRequestedOrientation" // method name
                     , "(I)V" // signature
                     , orientation);

    If it can be useful for other people in the forum...

Log in to reply