Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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?

    Thanx!



  • 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() )
        {
            activity.callMethod<void>
                    ("setRequestedOrientation" // method name
                     , "(I)V" // signature
                     , orientation);
        }
    }
    

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


Log in to reply