和群友
一起研究出来的方法。
直接上代码:
main.qml
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Window 2.0
Window {
title: qsTr("Hello World")
width: Screen.width
height: Screen.height
visible: true
color: "#ff00ff"
Rectangle {
y: Screen.height - Screen.desktopAvailableHeight
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableHeight
color: "#a1a1a1"
}
}
需要注意的是:一定要用Window做主窗口,而且导入的一定要是2.0版本的,不能是2.1或者是2.2(至少我测试的时候是这样)
~~~~~更新ApplicationWindow的方法~~~~~
上次写的只能用在Window上,而且要2.0版本,有点坑。
今天研究了下,发现ApplicationWindow也是可以的,代码差不多。
效果一样。截图就不单独贴了。
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Window 2.0
ApplicationWindow {
title: qsTr("Hello World")
width: Screen.width
height: Screen.height
visible: true
color: "#ff00ff"
modality: Qt.NonModal
Rectangle {
y: Screen.height - Screen.desktopAvailableHeight
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableHeight
color: "#a1a1a1"
}
Component.onCompleted: {
this.showNormal();
}
}