Qt 5.3.1 android中的全屏模式问题

Qt 5.3.1 android中的全屏模式问题,android,qt,qml,fullscreen,Android,Qt,Qml,Fullscreen,我正在用qml(qt5.3.1,macosx10.8.5)开发一个android应用程序(API 19)。全屏模式工作,但有一个小问题。导航栏已隐藏,但应用程序未使用此空间() main.cpp ... QApplication app(argc, argv); QQuickView viewer1(QUrl(QStringLiteral("qrc:///main.qml"))); viewer1.setResizeMode(QQuickView::SizeRootObjectToView);

我正在用qml(qt5.3.1,macosx10.8.5)开发一个android应用程序(API 19)。全屏模式工作,但有一个小问题。导航栏已隐藏,但应用程序未使用此空间()

main.cpp

...
QApplication app(argc, argv);
QQuickView viewer1(QUrl(QStringLiteral("qrc:///main.qml")));
viewer1.setResizeMode(QQuickView::SizeRootObjectToView); // no effect
viewer1.showFullScreen();
return app.exec();
...
main.qml

import QtQuick 2.2

Rectangle {
    color: "red"
    width: 100
    height: 100
}
我尝试将android:theme=“@android:style/theme.NoTitleBar.Fullscreen”添加到AndroidManifest.xml,但没有解决方案


使用模拟器和设备进行测试。有什么想法吗?

这个问题在即将发布的5.3.2版中得到了解决。
您还应设置系统UI可见性标志:

在Android代码中:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_FULLSCREEN
          | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
          | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
          | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
QtAndroid::runOnAndroidThread([=]()
{
    QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
    QAndroidJniObject decorView = window.callObjectMethod("getDecorView", "()Landroid/view/View;");
    int flags = 0x00000002 | 0x00000400 | 0x00000100 | 0x00000200 | 0x00000004 | 0x00001000;
        decorView.callMethod<void>("setSystemUiVisibility", "(I)V", flags);
});
< Q> C++代码中的强> < <强>

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_FULLSCREEN
          | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
          | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
          | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
QtAndroid::runOnAndroidThread([=]()
{
    QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
    QAndroidJniObject decorView = window.callObjectMethod("getDecorView", "()Landroid/view/View;");
    int flags = 0x00000002 | 0x00000400 | 0x00000100 | 0x00000200 | 0x00000004 | 0x00001000;
        decorView.callMethod<void>("setSystemUiVisibility", "(I)V", flags);
});
QtAndroid::runOnAndroidThread([=]()
{
QAndroidJniObject window=QtAndroid::androidActivity().callObjectMethod(“getWindow”,“Landroid/view/window;”);
QAndroidJniObject decorView=window.callObjectMethod(“getDecorView”,“()Landroid/view/view;”);
int flags=0x00000002 | 0x00000400 | 0x00000100 | 0x00000200 | 0x00000004 | 0x000001000;
decorView.callMethod(“设置系统兼容性”,“I)V”,标志);
});
您可以从中获取标志代码


Dovranito回答的附加信息 如果androidmanifest.xml中有“android:theme=”definition,则必须删除

例如,您的androidmanifest.xml是

<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:label="superslot" android:extractNativeLibs="true">
最后,您不会忘记添加main.cpp、
#include
、.pro文件add
QT+=androidxtras

就这些

setFullScreenMode(true);