Temporarily, programmatically disable screen rotation in Qt

Note: This question is about the Qt C ++ framework, not the regular Java API. In Java, this question has already been answered .

In the main menu of my application, I really do not want to worry about different types of screen rotation. I would like to turn off screen rotation until the user switches to other views where screen rotation makes sense. For the main menu, I want to use only portrait view.

How to do it? How to control the screen rotation of the application?

+5
source share
1 answer

You can set the orientation using

QAndroidJniObject activity = QtAndroid::androidActivity();
activity.callMethod<void>("setRequestedOrientation", "(I)V", orientation);

- int . , (, 0 , 1 -1 ), , ,

QAndroidJniObject::getStaticField<int>("android.content.pm.ActivityInfo", "SCREEN_ORIENTATION_LANDSCAPE");

.

fooobar.com/questions/4849933/.... , , , , , .

0

Source: https://habr.com/ru/post/1620323/


All Articles