您的位置:首页 > 移动开发 > Android开发

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

2013-04-05 16:51 676 查看
在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"

这样就可以实现强制横屏,不会自动旋屏了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  QT Android Landscape 横屏