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

Enable locking screen orientation programmatically

    XMLWordPrintable

    Details

    • Type: User Story
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 6.2.0
    • Fix Version/s: 6.4
    • Component/s: Quick: Other
    • Labels:
      None
    • Platform/s:
      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

              Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              vminenko Vladimir Minenko
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              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