qml之StackView的使用

QQ:609162385
在这里插入图片描述

import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
Window {
    id: idWindow;
    width:  1024.0;
    height: 768.0;
    title: qsTr("qmlStackViewDemo  qq:609162385")
    property int divi_line: 1
    Component.onCompleted:   {
        idWindow.visible = true;
    }

    Component.onDestruction: {
    }
    QtObject {
        id: idMainPriv;
        function push(index){
            switch(index){
            case 0:
                idstackview.push(idescview0,StackView.Immediate);
                break;
            case 1:
                idstackview.push(idescview1,StackView.Immediate);
                break;
            case 2:
                idstackview.push(idescview2,StackView.Immediate);
                break;
            case 3:
                idstackview.push(idescview3,StackView.Immediate);
                break;
            case 4:
                idstackview.push(idescview4,StackView.Immediate);
                break;
            case 5:
                idstackview.push(idescview5,StackView.Immediate);
                break;
            case 6:
                idstackview.push(idescview6,StackView.Immediate);
                break;
            default:
                break;
            }
        }
        function pop(){
            idstackview.pop(StackView.Immediate)
        }
    }

    StackView{id: idstackview; anchors.fill: parent;
        Component{ id: idescview0;     Rectangle{color: "#FFFFFF"} }
        Component{ id: idescview1;      Rectangle{color: "#FFF68F"} }
        Component{ id: idescview2;      Rectangle{color: "#FF83FA"} }
        Component{ id: idescview3;      Rectangle{color: "#CD1076"} }
        Component{ id: idescview4;      Rectangle{color: "#8B0A50"}}
        Component{ id: idescview5;      Rectangle{color: "#3B3B3B"} }
        Component{ id: idescview6;     Rectangle{color: "#080808"} }
    }

    Rectangle{ id: idfoot
        width: idWindow.width; height: 72; anchors.bottom: parent.bottom
        Rectangle{width: parent.width; height: divi_line;color: "#DAA520";}
        TabBar {
            id: tabBar; width: idWindow.width; height: 72 - divi_line;anchors.bottom: parent.bottom;
            background: Rectangle{color: "#3A3223"}
            currentIndex: 0
            onCurrentIndexChanged: {idMainPriv.pop();idMainPriv.push(currentIndex)}

            TabButton { width: height*1.2;height: 70;
                background: Rectangle{color: "#FFFFFF"}
            }
            TabButton { width: height*1.2;height: 70;
                background: Rectangle{color: "#EEEE00"}
            }
            TabButton { width: height*1.5;height: 70;
                background: Rectangle{color: "#FF83FA"}
            }
            TabButton{ width: height*1.2;height: 70;
                background: Rectangle{color: "#CD1076"}
            }
            TabButton {width: height*1.2;height: parent.height
                background: Rectangle{color: "#8B0A50"}
            }
            TabButton {width: height*1.2;height: parent.height
                background: Rectangle{color: "#3B3B3B"}
            }
            TabButton {width: height*1.2;height: parent.height
                background: Rectangle{color: "#080808"}
            }
        }
    }
}

猜你喜欢

转载自blog.csdn.net/cqltbe131421/article/details/83148918