Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-102194

Enable locking screen orientation programmatically

    XMLWordPrintable

Details

    • User Story
    • Resolution: Unresolved
    • P3: Somewhat important
    • 6.4
    • 6.2.0
    • Quick: Other
    • None
    • Android, iOS/tvOS/watchOS

    Description

      I was following a few discussions on dev forums and had to realize that is apparently not possible to lock orientation programmatically with Qt API. People developer they own "utils" for this. Do they or I miss something?

      https://forum.qt.io/topic/126130/set-ios-device-orientation-programmatically-how/4

      Another user posted this code:

      #ifdef Q_OS_ANDROID
      // see https://falsinsoft.blogspot.com/2018/02/qml-change-android-screen-orientation.html
      // https://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_SENSOR_LANDSCAPE == 6
      // CREEN_ORIENTATION_SENSOR_LANDSCAPE == 0
      bool ApplicationUI::setScreenOrientationLandscape()
      {
          QAndroidJniObject activity = QtAndroid::androidActivity();
      
          if(activity.isValid())
          {
              activity.callMethod<void>("setRequestedOrientation", "(I)V", 0);
              return true;
          }
      
          return false;
      }
      #endif
      
      #ifdef Q_OS_IOS
      void ApplicationUI::setLandscape()
      {
          // setLandscapeLeft
          IosUtil* mIosUtil = nullptr;
          mIosUtil = new IosUtil(this);
          mIosUtil->setLandscape();
      }
      #endif

      As a PM of iOS, I wish this simple feature should be available as API. Other takes?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              vminenko Vladimir Minenko
              Vladimir Minenko Vladimir Minenko
              Volker Hilsheimer Volker Hilsheimer
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes