qml android 隐藏状态,android - QML screen orientation lock - Stack Overflow

本文指导如何创建一个源代码外部目录,复制并编辑AndroidManifest.xml以更改屏幕方向,然后在qmake文件中设置ANDROID_PACKAGE_SOURCE_DIR,确保在构建时使用定制的AndroidManifest.xml。这种方法允许开发者根据需求自定义应用的屏幕布局。

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

The way to do this is-

Create an out-of-source directory - let's call it "templates" (can be anything)

Copy the AndroidManifest.xml into "templates" from -

/android_armv7/src/android/templates/AndroidManifest.xml

Edit the copied AndroidManifext.xml with your favorite editor and change the orientation from "unspecified" to "sensorLandscape" (or anything else you prefer) and save the file.

In the qmake file (*.pro) of your project, add the following line -

ANDROID_PACKAGE_SOURCE_DIR = #in case you added the directory one above the source directory, path to your templates directory = "../templates"

Build and Run. You should now see that the Orientation is fixed to whatever you have specified in the custom AndroidManifest.xml file

To understand what really is happening - here's the qt reference, look for ANDROID_PACKAGE_SOURCE_DIR

In case the link doesn't work in future, here's the relevant bits -

"ANDROID_PACKAGE_SOURCE_DIR: This variable can be used to specify a

directory where additions and modifications can be made to the default

Android package template. The androiddeployqt tool will copy the

application template from Qt into the build directory, and then it

will copy the contents of the ANDROID_PACKAGE_SOURCE_DIR on top of

this, overwriting any existing files. The update step where parts of

the source files are modified automatically to reflect your other

settings is then run on the resulting merged package. If you, for

instance, want to make a custom AndroidManifest.xml for your

application, then place this directly into the folder specified in

this variable. You can also add custom Java files in

ANDROID_PACKAGE_SOURCE_DIR/src."

QtCreator - 4.2.1, Qt - 5.8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值