在先前的文章" 如何在Ubuntu手机中使得一个应用是全屏的应用 - Ubuntu.Components 1.3",我们介绍了如何实现一个全屏的应用.但是在那里的文章中,我们的方法不能完全覆盖手机的状态显示区域.比如:
从上面的两张图中,我们可以看出来一些差别.左边的一个图里,还是有手机状态的显示.究其原因,还是因为MainView不让我们完全覆盖所有的区域.那么我们怎么实现一个完全的全屏应用呢?
在我们的下面的例子中,我们完全抛弃MainView.我们选用Window来完成我们的界面:
Main.qml
import QtQuick 2.4
import Ubuntu.Components 1.3
import QtQuick.Window 2.2
//Rectangle {
// width: Screen.width
// height: Screen.height
// color:"red"
//}
Window {
id: main
width: Screen.width
height: Screen.height
// special flag only supported by Unity8/MIR so far that hides the shell's
// top panel in Staged mode
flags: Qt.Window | 0x00800000
Image {
anchors.fill: parent
source: "images/pic.jpg"
}
Label {
anchors.centerIn: parent
text: "This a full screen app"
fontSize: "x-large"
}
Component.onCompleted: {
console.log("visibility: " + main.visibility )
console.log("width: " + Screen.width + " height: " + Screen.height )
}
}
在上面的代码中,我们同时也设置如下的flags:
flags: Qt.Window | 0x00800000
这样我们就可以完全实现一个全屏的应用了.