QML-垂直滑动视图? [英] QML - Vertical Swipe View?
问题描述
是否可以在QML中使用SwipeView进行垂直滑动而不是水平滑动?
Is it possible to use the SwipeView in QML for vertical swiping rather than horizontal?
我希望SwipeView的Page内容垂直浮动,因此用户必须上下滚动才能在Pages之间导航.
I'd like the Page contents of a SwipeView to float vertically, so a user has to scroll up and down to navigate between Pages.
如果不可能的话,我该怎么办?
If this is not possible how would I go about it?
更新,此功能已添加到QT中,如下所示:
UPDATE This functionality has been added to QT as seen here:
http://doc -snapshots.qt.io/qt5-dev/qml-qtquick-controls2-swipeview.html#orientation-prop
推荐答案
经过更多的研究,我想出了一个很好的解决方案,使用ListView/ListModel/ListDelegate-在这里发布给其他想要实现相同目标的人
After some more research I came up with a solution that works fine, using a ListView/ListModel/ListDelegate - posting it here for others who wants to achieve the same.
QML:
ListView {
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
right: parent.right
}
model: ListModel {
id: listModel
ListElement {
text: "1"
}
ListElement {
text: "2"
}
ListElement {
text: "3"
}
}
delegate: Page {
width: ListView.view.width
height: ListView.view.height
Text {
anchors.centerIn: parent
text: model.text
}
}
}
这篇关于QML-垂直滑动视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!