首页 > 解决方案 > 将动画应用于 InputPanel QML 类型的问题

问题描述

我有以下输入面板:

        InputPanel{
                id: inputPanel
                visible: false
                y : window.height/2
                width: window.width
                height: window.height/2
                transitions: Transition {

                    NumberAnimation {
                        target: inputPanel
                        property: "height"
                        duration: 500
                        easing.type: Easing.InOutQuad
                    }

                }
            }

但是NumberAnimation没有效果,SmoothedAnimationPathAnimationSequentialAnimation也是如此。
我使用 Qt 5.14

任何帮助表示赞赏。

标签: qtanimationqmlqt5qtquick2

解决方案


你想要一个行为

InputPanel {
    Behavior on width {
        NumberAnimation {
            duration: 2000
        }
    }
    width: 400
    active: true
}

正如 folibis 所提到的,转换是为了状态变化。


推荐阅读