There is also a QML-only way to go fullscreen.
You can use this if you are not using QDeclarativeView but QQmlApplicationEngine, since the latter doesn't inherits QWidget and has not the method showFullScreen().
import QtQuick 2.2
import QtQuick.Controls 1.1
ApplicationWindow {
id: window
visible: true
visibility: "FullScreen"
width: 640
height: 480
Button {
text: "exit fullscreen"
onClicked: window.visibility = "Windowed"
}
}
But it's important to use ApplicationWindow as the root-element and not Rectangle. For ApplicationWindow you have to import QtQuick.Controls.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…