首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >qml变化动画/转换速度

qml变化动画/转换速度
EN

Stack Overflow用户
提问于 2018-03-20 14:56:50
回答 1查看 3.1K关注 0票数 1

我使用的是QT5.10和SwipeView。我想改变滑动动画的速度,但是在看完文档之后,我看不出是怎么回事。有办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-20 17:26:41

我尝试这样做的原因是,不知道为什么,滑动转换动画非常慢(参见下面)--这是我的代码:

代码语言:javascript
复制
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实现的代码就解决了这个问题:

代码语言:javascript
复制
  ....  
  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替换为更大的值。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49387541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档