QT里用QML写的Android程序关于设置横屏的方法

来源:互联网 发布:java 判断object 类型 编辑:程序博客网 时间:2024/05/29 19:56

在QT里用QML写的Android程序,在main.cpp里用以下代码

       QScopedPointer<QApplication>app(createApplication(argc,argv));

    QmlApplicationViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);// ScreenOrientationLockPortrait);// ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/QMLOne/main.qml"));
    viewer.showFullScreen();//showExpanded();
是无法设置横屏的,需在生成的android文件夹里找到AndroidManifest.xml,修改里面的

<activity android:name="org.kde.necessitas.origo.QtActivity" android:configChanges="orientation|locale|fontScale|keyboard|keyboardHidden" android:label="@string/app_name">

这句,在后面增加   android:screenOrientation="landscape"

这样就可以实现强制横屏,不会自动旋屏了。


原创粉丝点击