【问题标题】:Drawer animation in QMLQML 中的抽屉动画
【发布时间】:2020-08-15 03:41:50
【问题描述】:

如何在 QML 中更改Drawer 类型的动画(即持续时间和缓动曲线)? 我试过这个:

PropertyAnimation{
            easing.type: Easing.InOutQuad
            easing.amplitude: 1000
            easing.period : 1000
}

但它没有效果。(抱歉,QML 中动画类型的多样性让我感到困惑,我无法尝试所有可能的选项)

【问题讨论】:

    标签: qt animation qml


    【解决方案1】:

    您需要覆盖此处记录的 Popup::enter 转换:

    https://doc.qt.io/qt-5/qml-qtquick-controls2-popup.html#enter-prop

    注意,抽屉实现对它如何进入和离开屏幕做了很多假设,所以如果你不小心很容易破坏它。

    您可以在此处查看默认设置:

    https://github.com/qt/qtquickcontrols2/blob/dev/src/imports/controls/Drawer.qml

        enter: Transition { SmoothedAnimation { velocity: 5 } }
        exit: Transition { SmoothedAnimation { velocity: 5 } }
    

    所以,从那里开始,慢慢调整,直到你得到你想要的。

    【讨论】:

      猜你喜欢
      • 2012-12-04
      • 2014-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      相关资源
      最近更新 更多