简体   繁体   English

Qt for android:更改应用程序图标

[英]Qt for android: change the application icon

我将如何更改针对 android 的 Qt 项目的图标,以便应用程序的启动器具有此图标?

You should create an Android manifest file and edit it in Qt Creator.您应该创建一个 Android 清单文件并在 Qt Creator 中对其进行编辑。 Go to Projects > Build Android APK > Details转到项目 > 构建 Android APK > 详细信息

Now Select Create Templates to create the manifest file and to open it in editor :现在选择创建模板来创建清单文件并在编辑器中打开它:

在此处输入图片说明

As shown in the picture, you can set three versions of icons for your application with low, medium, and high DPI values, from left to right.如图所示,您可以为您的应用程序设置三个版本的图标,从左到右具有低、中、高 DPI 值。

This new way of making an android manifest file is available since Qt 5.4 along Qt Creator 3.3.从 Qt 5.4 和 Qt Creator 3.3 开始,可以使用这种制作 android 清单文件的新方法。 There used to be a Create AndroidManifest.xml button in Projects->Run->Deploy in previous versions.在以前的版本中, Projects->Run->Deploy中曾经有一个Create AndroidManifest.xml按钮。

Open Run settings of your project and select Create AndroidManifest.xml, then you'll be able to modify the manifest which should include stuff like the icon.打开项目的运行设置并选择创建 AndroidManifest.xml,然后您将能够修改清单,其中应包含图标之类的内容。

Refer to this: http://qt-project.org/doc/qtcreator-3.2/creator-deploying-android.html参考这个: http : //qt-project.org/doc/qtcreator-3.2/creator-deploying-android.html

Look at the this article about anatomy of a Qt 5 for Android application.看看这篇关于 Qt 5 for Android 应用程序剖析的文章 You should attach to your project file AndroidManifest.xml , where you can define icon of application .您应该附加到您的项目文件AndroidManifest.xml ,您可以在其中定义应用程序的图标

I'm going to update this a bit: Using the AndroidManifest.xml, you can add android:icon="@mipmap/ic_launcherx" and android:roundIcon="@mipmap/ic_launcherx_round" to <application ... .我要稍微更新一下:使用 AndroidManifest.xml,您可以将android:icon="@mipmap/ic_launcherx"android:roundIcon="@mipmap/ic_launcherx_round"<application ...

You can generate the icons simply in the android studio and add them to your project's android folder (ie: /android/res/[mipmap-hdpi]/[ic_launcherx.png] )您可以简单地在 android studio 中生成图标并将它们添加到您项目的 android 文件夹中(即: /android/res/[mipmap-hdpi]/[ic_launcherx.png] )

So this adds an icon and a rounded icon to the application.所以这会向应用程序添加一个图标和一个圆形图标。 The interesting part, however, is the name;然而,有趣的部分是名字; leaving the name @mipmap/ic_launcher will cause a "Error: Duplicate resource" ... So don't forget to change it.保留名称@mipmap/ic_launcher将导致"Error: Duplicate resource" ......所以不要忘记更改它。 After that, a normal build should succeed =)之后,正常构建应该会成功=)

It is even more simplified in the QT Creator 4.12:在 QT Creator 4.12 中更加简化:

In the latest Qt Creator one is able to click on projects > Build > "Create Templates"在最新的 Qt Creator 中,可以单击项目 > 构建 > “创建模板”

在此处输入图片说明

After that you can edit the Manifest as @Nejat explained:之后,您可以按照@Nejat 的解释编辑清单:

在此处输入图片说明

Cheers!干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM