Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to lock screen orientation (Android&Qt5.1)
Forum Updated to NodeBB v4.3 + New Features

How to lock screen orientation (Android&Qt5.1)

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 5 Posters 11.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zlutor
    wrote on last edited by
    #1

    Is there any solution for locking screen orientation to portrait mode?

    Something equivalent to good old solution in main.cpp:

    @QmlApplicationViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Moster
      wrote on last edited by
      #2

      1 solution would be the android manifest.

      just add android:screenOrientation="portrait" for the main activity

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zlutor
        wrote on last edited by
        #3

        could you, please, alter my manifest file below?

        @<?xml version='1.0' encoding='utf-8'?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" package="com.mycomp.exampleapp" android:versionCode="1">
        <application android:icon="@drawable/icon" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtApplication">
        <activity android:configChanges="orientation|locale|fontScale|keyboard|keyboardHidden|navigation" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtActivity">
        <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <meta-data android:resource="@array/qt_sources" android:name="android.app.qt_sources_resource_id"/>
        <meta-data android:value="@string/repository" android:name="android.app.repository"/>
        <meta-data android:resource="@array/qt_libs" android:name="android.app.qt_libs_resource_id"/>
        <meta-data android:resource="@array/bundled_libs" android:name="android.app.bundled_libs_resource_id"/>
        <meta-data android:value="iqchallengesliderpro" android:name="android.app.lib_name"/>
        <!-- Deploy Qt libs as part of package -->
        <meta-data android:value="0" android:name="android.app.bundle_local_qt_libs"/>
        <meta-data android:resource="@array/bundled_in_lib" android:name="android.app.bundled_in_lib_resource_id"/>
        <meta-data android:resource="@array/bundled_in_assets" android:name="android.app.bundled_in_assets_resource_id"/>
        <!-- Run with local libs -->
        <meta-data android:value="1" android:name="android.app.use_local_qt_libs"/>
        <meta-data android:value="/data/local/tmp/qt/" android:name="android.app.libs_prefix"/>
        <meta-data android:value="libs/libgnustl_shared.so:lib/libQt5QuickParticles.so:plugins/platforms/android/libqtforandroidGL.so:" android:name="android.app.load_local_libs"/>
        <meta-data android:value="jar/QtAndroid.jar:" android:name="android.app.load_local_jars"/>
        <meta-data android:value=":" android:name="android.app.static_init_classes"/>
        <!-- Messages maps -->
        <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
        <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
        <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
        <!-- Messages maps -->
        <!-- Splash screen -->
        <meta-data android:resource="@layout/splash" android:name="android.app.splash_screen"/>
        <!-- Splash screen -->
        </activity>
        </application>
        <supports-screens android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" android:largeScreens="true"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        </manifest>@

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Moster
          wrote on last edited by
          #4

          @ <?xml version='1.0' encoding='utf-8'?>
          <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" package="com.mycomp.exampleapp" android:versionCode="1">
          <application android:icon="@drawable/icon" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtApplication">
          <activity android:configChanges="orientation|locale|fontScale|keyboard|keyboardHidden|navigation" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:screenOrientation="portrait">
          <intent-filter>
          <action android:name="android.intent.action.MAIN"/>
          <category android:name="android.intent.category.LAUNCHER"/>
          </intent-filter>
          <meta-data android:resource="@array/qt_sources" android:name="android.app.qt_sources_resource_id"/>
          <meta-data android:value="@string/repository" android:name="android.app.repository"/>
          <meta-data android:resource="@array/qt_libs" android:name="android.app.qt_libs_resource_id"/>
          <meta-data android:resource="@array/bundled_libs" android:name="android.app.bundled_libs_resource_id"/>
          <meta-data android:value="iqchallengesliderpro" android:name="android.app.lib_name"/>
          <!-- Deploy Qt libs as part of package -->
          <meta-data android:value="0" android:name="android.app.bundle_local_qt_libs"/>
          <meta-data android:resource="@array/bundled_in_lib" android:name="android.app.bundled_in_lib_resource_id"/>
          <meta-data android:resource="@array/bundled_in_assets" android:name="android.app.bundled_in_assets_resource_id"/>
          <!-- Run with local libs -->
          <meta-data android:value="1" android:name="android.app.use_local_qt_libs"/>
          <meta-data android:value="/data/local/tmp/qt/" android:name="android.app.libs_prefix"/>
          <meta-data android:value="libs/libgnustl_shared.so:lib/libQt5QuickParticles.so:plugins/platforms/android/libqtforandroidGL.so:" android:name="android.app.load_local_libs"/>
          <meta-data android:value="jar/QtAndroid.jar:" android:name="android.app.load_local_jars"/>
          <meta-data android:value=":" android:name="android.app.static_init_classes"/>
          <!-- Messages maps -->
          <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
          <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
          <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
          <!-- Messages maps -->
          <!-- Splash screen -->
          <meta-data android:resource="@layout/splash" android:name="android.app.splash_screen"/>
          <!-- Splash screen -->
          </activity>
          </application>
          <supports-screens android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" android:largeScreens="true"/>
          <uses-permission android:name="android.permission.INTERNET"/>
          <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
          </manifest>
          @

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mikyago
            wrote on last edited by
            #5

            This worked for me too, thanks.
            Anyway it sounds strange to me that there is not something like:
            @Window.setOrientation@
            @Window.lockOrientation@
            @Screen.setOrientation@
            @Screen.lockOrientation@

            ps. I use qt 5.4 :)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mikyago
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • deleted57D Offline
                deleted57D Offline
                deleted57
                wrote on last edited by
                #7

                In case you need a function call to set orientation you can use the info in this post:

                QML: Change Android screen orientation programmatically

                F 1 Reply Last reply
                0
                • deleted57D deleted57

                  In case you need a function call to set orientation you can use the info in this post:

                  QML: Change Android screen orientation programmatically

                  F Offline
                  F Offline
                  firestore
                  wrote on last edited by
                  #8

                  @Suppaman
                  The best solution...
                  https://forum.qt.io/topic/52250/how-can-i-stop-qtcreator-from-overwriting-my-androidmanifest-xml

                  Raj Reddy
                  Ankiom Soft
                  skype: raja.anki
                  ph: +1 248 764 5597
                  email: raj@ankiom.com

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved