前言
有时会用到 和手机那种用手指滑动, 页面左右滑动的效果。
那么我们就来介绍 下 SwipeView
用法很简单:
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Tabs")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: 1 // 当前页面的索引 1
item{ // 这就是你要添加的页面1
}
item { //页面2
}
}
// 这个的话, 就是显示 页指示符
PageIndicator {
id: indicator
count: swipeView.count
currentIndex: swipeView.currentIndex
anchors.bottom: swipeView.bottom
anchors.horizontalCenter: parent.horizontalCenter
}
}
效果图:
在这里插入图片描述