简体   繁体   English

与stackview一起使用时Swipeview不显示屏幕

[英]Swipeview is not showing screen when used with stackview

I am implementing stackview in my application. 我在我的应用程序中实现stackview。

main.qml main.qml

   ApplicationWindow {
    id: window
    width: 360
    height: 520
    visible: true
    title: "City Explorer"
    color:"#FAF7F7"

    Loader {
        id: splashLoader
        anchors.fill: parent
        source: "../AppFooter.qml"
        visible: true
    }


    footer: TabBar {
        id: appfooter
        currentIndex: 0
        background: Rectangle {
            color: "#d6d6d6"
        }

        TabButton {
            id: control1
            background: Rectangle {
                width: 44
                height: 40
                border.color: "#000000"
                color: "#d6d6d6"
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.Bottom
                Image {
                    id: contentImage

                    fillMode: Image.PreserveAspectFit
                }
            }
            onClicked: {
                contentImage.source = "../images/dashboard_active.png"
                contentImage1.source = "../images/settings_inactive.png"
            }
        }
        TabButton {
            id: control2
               background: Rectangle {
                    width: 44
                    height: 40
                    color: "#d6d6d6"
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
                    Image {
                        id: contentImage1
                        fillMode: Image.PreserveAspectFit
                    }
               }
               onClicked: {
                   contentImage.source = "../images/dashboard_inactive.png"
                   contentImage1.source = "../images/settings_active.png"
                   contentImage2.source = "../images/bookings_inactive.png"
               }
        }
    }

    header: ToolBar {
        id:appheader
        visible: false
        RowLayout {
            spacing: 20
            anchors.fill: parent

            ToolButton {
                id:backButton
                visible: false
                contentItem: Image {
                    fillMode: Image.Pad
                    horizontalAlignment: Image.AlignHCenter
                    verticalAlignment: Image.AlignVCenter
                    source: stackView.depth > 1 ? "../images/back.png" : ""
                }
                onClicked: {
                    if (stackView.depth > 1) {
                        stackView.pop()   
                    } else {
                    }
                }
            }

            Label {
                id: titleLabel
                text: "City Explorer"

                font.pixelSize: 20
                elide: Label.ElideRight
                horizontalAlignment: Qt.AlignHCenter
                verticalAlignment: Qt.AlignVCenter
                Layout.fillWidth: true
            }
        }
    }

    StackView {
       id: stackView
       initialItem: Pane {
          id: pane
       }
    }
}

SightListViewForm.ui.qml SightListViewForm.ui.qml

Item {
    width: 360
    height: 520
    property alias mouseArea: mouseArea

    MouseArea {
        id: mouseArea
        anchors.rightMargin: 0
        anchors.bottomMargin: 0
        anchors.fill: parent

        Rectangle {
            id: rectangle
            x: 38
            y: 21
            width: 200
            height: 200
            color: "#e03636"

            Label {
                id: label
                x: 61
                y: 150
                width: 154
                height: 28
                text: qsTr("Overlapping view")
                z: 2
            }
        }
    }
}

SettingsForm.ui.qml SettingsForm.ui.qml

Item {
    width: 400
    height: 400

    Image {
        id: image
        x: 101
        y: 85
        width: 150
        height: 162
        source: "images/singapore.png"

        Label {
            id: label
            x: 8
            y: 100
            width: 142
            height: 23
            text: qsTr("Label")
        }
    }
}

AppFotter.qml AppFotter.qml

SwipeView {
    id: swipeView
    anchors.fill: parent
    currentIndex: showfooter.currentIndex

        DashboardListView{
        id:dashboard
        }

        Settings{
        id:setting
        }
}

DashBoardListViewForm.ui.qml DashBoardListViewForm.ui.qml

Item {
    id: item1
    width: 360
    height: 520
    property alias button: button
    visible: true

    Button {
        id: button
        x: 130
        y: 287
        text: qsTr("Button")
        onClicked: {
                console.log("SightListView.qml")
                stackview.push("SightListView.qml")
            }
    }
}

初始加载窗口并按下按钮stachview.push将加载新窗口

SightListViewForm已加载

现在,当我从页脚设置视图中选择设置图标时,已加载设置视图,但它位于SightListViewForm后面。我希望设置视图在其他选项卡中位于顶部

On pressing button when view is initially loaded it calls stackview.push which loads SightListViewForm and then when I press Footer's setting icon my settings view is coming behind SightListViewForm. 最初加载视图时,在按下按钮时会调用stackview.push,该加载会加载SightListViewForm,然后当我按Footer的设置图标时,我的设置视图位于SightListViewForm后面。 How do I change this behaviour of Stackview or Swipeview or I am missing something that should be added. 如何更改Stackview或Swipeview的这种行为,或者我缺少应添加的内容。 I am not clear on this. 我不清楚。

It turns out I have to keep stackview in footer instead of main.qml 原来我必须将stackview保留在页脚而不是main.qml中

DashboardListView{
    id:dashboard
        StackView {
           id: stackView

           initialItem: Pane {
              id: pane
           }
        }
    }

and

Create AppFooter in main.qml 在main.qml中创建AppFooter

AppFooter{
    id:appfooterglobal
    visible: false
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM