简体   繁体   English

QML-使用一个按钮锁定/解锁屏幕方向(Android和最终的ios)

[英]QML - Lock/Unlock screen orientation with one button (android and eventually ios)

I've been searching for a solution to this but I could only find a way to force the whole app to stay in either landscape or portrait, via the android manifest. 我一直在寻找解决方案,但我只能通过Android清单来找到一种方法来强制整个应用程序保持横向或纵向。 In my app the user is able to customize his UI and one important aspect of that is the screen orientation. 在我的应用程序中,用户可以自定义他的UI,其中一个重要方面是屏幕方向。 I'd like to create a button where the user could change the orientation and lock it that way. 我想创建一个按钮,用户可以在其中更改方向并以这种方式锁定它。

Thank you for your time. 感谢您的时间。

I don't think it is possible through QML but you may bind your qml button to change orientation by setting orientation of QQmlApplicationViewer object. 我认为无法通过QML但是您可以通过设置QQmlApplicationViewer对象的方向来QQmlApplicationViewer按钮以更改方向。 You may find some information here . 您可以在此处找到一些信息。 In my experience I remember I forced orientation only in C++ . 以我的经验,我记得我只在C++定向。

So, you may need a class to export to QML which will toggle orientation (by setting value to the QQmlApplicationViewer and bind it with your button/checkbox in your qml interface. 因此,您可能需要一个类导出到QML ,这将切换方向(通过将值设置为QQmlApplicationViewer并将其与QQmlApplicationViewer界面中的按钮/复选框绑定)。

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

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