我使用的是QT5.10和SwipeView。我想改变滑动动画的速度,但是在看完文档之后,我看不出是怎么回事。有办法解决这个问题吗?
发布于 2018-03-20 17:26:41
我尝试这样做的原因是,不知道为什么,滑动转换动画非常慢(参见下面)--这是我的代码:
ColumnLayout{
anchors.fill: parent
Item{
id:modulecontainer
Layout.fillHeight: true
Layout.fillWidth: true
SwipeView{
id: moduleview
anchors.fill: parent
interactive: loggedUser.role==User.AdminRole
clip: true
orientation: Qt.Horizontal
Item {
id: firstPage
Loader {
anchors.fill: parent
id:moduleLoader
}
}
Item {
id: secondPage
Rectangle{
anchors.fill: parent
color: "red"
}
}
}
}
}

我仅从contentItem的源代码中提取SwipeView实现的代码就解决了这个问题:
....
SwipeView{
id: moduleview
....
contentItem: ListView {
model: moduleview.contentModel
interactive: moduleview.interactive
currentIndex: moduleview.currentIndex
spacing: moduleview.spacing
orientation: moduleview.orientation
snapMode: ListView.SnapOneItem
boundsBehavior: Flickable.StopAtBounds
highlightRangeMode: ListView.StrictlyEnforceRange
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 250
// min:10
maximumFlickVelocity: 4 * (moduleview.orientation ===
Qt.Horizontal ? width : height)
}
}
....结果:

不知道为什么这会解决这个问题,但我要分享一下,以防其他人面临同样的问题。如果需要更多的动画速度,只需将maximumFlickVelocity因子从4替换为更大的值。
https://stackoverflow.com/questions/49387541
复制相似问题