简体   繁体   中英

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. In my app the user is able to customize his UI and one important aspect of that is the screen orientation. 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. You may find some information here . In my experience I remember I forced orientation only in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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