Qt quick qml设置ios窗口满屏和设置状态栏颜色

来源:互联网 发布:小甲鱼c语言视频怎么样 编辑:程序博客网 时间:2024/06/05 20:16

先上代码随后说明,为了这个全屏真是折磨死人了。

import QtQuick 2.7
//问题在import QtQuick.Window 2.0,如果用其他版本Window都没法全屏,太坑人了
import QtQuick.Window 2.0
Window {
    visible: true
    width: Screen.width
    height: Screen.height
    //这是设置标题栏颜色的代码
    Rectangle
    {
        y: Screen.height - Screen.desktopAvailableHeight  
        width: Screen.desktopAvailableWidth  
        height: Screen.desktopAvailableHeight  
        color: "#00ff00"
    }
    Login
    {
        anchors.fill: parent
    }
   /* MainForm {
        anchors.fill: parent
        mouseArea.onClicked: {
            Qt.quit();
        }
    }*/
}
上图看一下这是window 2.0版本全屏的效果
这是另一种方法也可以全屏即使不是window 2.0版本的也没问题
ApplicationWindow实现的
import QtQuick 2.7
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
ApplicationWindow
{
    title: qsTr("Test demo")
    width: Screen.width
    height: Screen.height
    visible: true
    color: "#0000ff"
    modality: Qt.NonModal
    //设置状态栏颜色
    Rectangle {
        y: Screen.height - Screen.desktopAvailableHeight
        width: Screen.desktopAvailableWidth
        height: Screen.desktopAvailableHeight
        color: "#00ff00"
    }
    Component.onCompleted: {
        this.showNormal();
    }
}

上图看效果

0 0
原创粉丝点击