How to set Android Screen Orientation in Qt

To be able to set your Android app orientation (to Portrait or Landscape mode) in Qt you have to modify AndroidManifest.XML manually. In this post I am going to describe where you can find this “AndroidManifest.XML”, because it does not exist in your project folder by default and how to modify it to set any desired Screen Orientation for your App.

  • First of all I assume that you have already created an android app but you don’t know how to add permissions for it. So, start by building your Qt for Android project first.


  • When you build a Qt project, a folder will be created by Qt to contain your build files. If you are using the default settings then this folder is located in the same folder where your project is located. It usually has a name similar to this: (Note that this is just an example and the folder name depends on the version and type of Qt build you are using but it has the same pattern)

build-myproject-Android_for_x86_GCC_4_9_Qt_5_5_0-Debug

  • If you go to the build folder mentioned above, there is a folder named “android-build” inside it. Inside android-build you will find a file named AndroidManifest.xml, copy that file.
  • Next, create a folder named “android-sources” inside your Qt project folder and copy AndroidManifest.xml there. (Note that your Qt project folder is the folder where your Qt PRO and source code CPP files etc. are located.)
  • Now right click your project in Qt Creator and select Add Existing Files. And select AndroidManifest.xml from the android-sources folder to add it to your project.


Note that you should have this in “Other files” section of your project.

2015-11-29 (3)

  • Now if you right click and open AndroidManifest.XML file using “Open in Plan Text Editor” mode, you can change all entries as you like. Search for “android:screenOrientation” and set the value at the right side of  “=” to “portrait” or “landscape“. After that if you run your app you will notice that it is set and locked to the orientation you specified.

5 Replies to “How to set Android Screen Orientation in Qt”

  1. Setting the screenOrientation to “landscape” locks it into one of the two landscape positions (i.e, screen will stay that way even when the phone is held in the other landscape view). To get screen tilt to either of two landscape views, use “sensorLandscape”.

    Thanks for the tutorial!

  2. .pro file also requires:

    android:DISTFILES += \
    android-sources/AndroidManifest.xml

    android:ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.