Qt 5.7 on Android 设置应用程序图标和名称

本文介绍如何在Qt项目中设置Android应用图标,包括创建Qt Widgets应用程序项目、复制AndroidManifest.xml文件并进行相应配置,以及如何修改工程文件.PRO来指定图标路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 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!)
先创建一个Qt Widgets application的工程(如果没有装过Qt for Android可以点击上面的红色字体去下载)

  • 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.)
然后什么都不用做,直接点“build”

  • 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

如果你使用的是默认设置会在你工程的同级目录下(注意,这里的同级目录不是指你的pro文件所在的目录,而是包涵pro文件的那个文件夹所在的目录,即pro文件的上级目录),会出现类似于“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.
在上面的那个目录下会有一个android-build”,在android-build”这个目录下又有一个名字为“AndroidManifest.xml”的文件,现在我们复制这个文件。

  • 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.)
下面,在工程文件所在目录(这里是pro文件所在的目录)下创建文件夹android-sources,将刚才的文件AndroidManifest.xml”复制到这里。

  • 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.
现在右键点击你Qt Creator中的工程,选择Add Existing Files(添加已存在的文件),将“AndroidManifest.xml”添加到工程中。如下图:

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

2015-11-29 (3)





  • 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.
现在双击Qt中的AndroidManifest.xml文件就打开如下界面,在"Application icon"处设置图标,这里有3种图标,分别为低、中、高。

Android Icon Change

  • Finally, open your Qt project (.PRO) file and append the following line at the bottom of it.
最后在工程文件.PRO文件中加上下面这名话。

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources

  • Now if you run your Qt Android project you should see that the icon is changed!
现在再次build,图标就备改变了。

关于程序名的更改也在AndroidManifest.xml中,就是把图标上面的“Application name”“Activity name”改了就可以了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高晓伟_Steven

相逢即是有缘,动力源于金钱。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值