How to set Android Screen Orientation in Qt

Posted on Posted in Android Tutorials, Qt Tutorials, Tutorials

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)


  • 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.

Leave a Reply

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