QML的SwipeView控件去除滑动效果

SwipeView默认是带滑动效果的,在做app主页的导航界面,不想让它有滑动效果。

Customizing Qt Labs Controls 里提到:

SwipeView can have a visual background item. The navigation is implemented by the content item.

SwipeView由背景和content item组成,导航是content item,是一个ListView 。

Background

SwipeView has no background item by default.

Content item

contentItem: ListView {

model: control.contentModel

currentIndex: control.currentIndex

spacing: control.spacing

orientation: Qt.Horizontal

snapMode: ListView.SnapOneItem

boundsBehavior: Flickable.StopAtBounds

highlightRangeMode: ListView.StrictlyEnforceRange

preferredHighlightBegin: 0

preferredHighlightEnd: 0

highlightMoveDuration: 250

  }

其中highlightMoveDuration属性控制切换速度,可以修改此项为0,使移动动画时间为0。

更多的说明可以直接看ListView属性即可。

比如简单地在SwipeView里设置以下代码即可:

        Component.onCompleted:

            contentItem.highlightMoveDuration = 0

猜你喜欢

转载自blog.csdn.net/fxy0325/article/details/84778942