When you create an Android app in Qt, the icon of your app remains the default set by Qt, it’s this one:
Usually you want to change it for a more meaningful icon. Follow the steps bellow to be able to change this icon in Qt.
- First of all Create a Qt Widgets application project for Android. (if you don’t have Qt for Android installed on your computer then you can refer to this post on how to get it done!)
- Next, without changing anything, just build the project. (You can run clean, qmake and then build which is what I always do to make sure things are alright.)
- 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.
- Now it’s time to actually add the icon to your android application in Qt. Double click AndroidManifest.xml to open the following window in Qt Creator. It is actually Qt’s Android Manifest editor. At the middle of the screen there are three buttons which you can press and select an icon for each one of them. They are used for setting Low DPI, Medium DPI and High DPI icons.
- Finally, open your Qt project (.PRO) file and append the following line at the bottom of it.
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
- Now if you run your Qt Android project you should see that the icon is changed!