qml之StackView
来源:互联网 发布:淘宝带图评价 淘气值 编辑:程序博客网 时间:2024/06/06 10:21
案例1:
import QtQuick 2.7import QtQuick.Window 2.2import QtQuick.Controls 1.4Window { id:root visible: true width: 640 height: 480 title: qsTr("Hello World") StackView { id: stackView anchors.fill: parent initialItem: ListView { model: ListModel { ListElement { title: "CircularGauge" } ListElement { title: "DelayButton" } ListElement { title: "Dial" } ListElement { title: "Gauge" } ListElement { title: "PieMenu" } ListElement { title: "StatusIndicator" } ListElement { title: "ToggleButton" } ListElement { title: "Tumbler" } } delegate: Button { width: stackView.width height: root.height * 0.125 text: title onClicked: { Qt.quit(); } } } }}
案例2:
import QtQuick 2.7import QtQuick.Window 2.2import QtQuick.Controls 2.0//使用StackView必须引入Window { visible: true width: 640 height: 480 title: qsTr("Hello World") StackView { id: stack initialItem: mainView anchors.fill: parent } Component { id: mainView Row { spacing: 10//间距 Button { text: "Push" onClicked: stack.push(mainView)//前推进 } Button { text: "Pop" enabled: stack.depth > 1//stack.dept记录数目 onClicked: stack.pop()//逆向推进 } Text { text: stack.depth//显示数目 } } }}
0 0