AnchorAnimation QML Type

动画显示锚点值的变化。更多

Import Statement: import QtQuick
Inherits:

Animation

属性

详细说明

AnchorAnimation 用于制作锚点变化的动画。

在下面的代码段中,我们为Rectangle 添加右锚设置了动画:

import QtQuick

Item {
    id: container
    width: 200; height: 200

    Rectangle {
        id: myRect
        width: 100; height: 100
        color: "red"
    }

    states: State {
        name: "reanchored"
        AnchorChanges { target: myRect; anchors.right: container.right }
    }

    transitions: Transition {
        // smoothly reanchor myRect and move into new position
        AnchorAnimation { duration: 1000 }
    }

    Component.onCompleted: container.state = "reanchored"
}

当在Transition 中使用 AnchorAnimation 时,它将为状态变化期间发生的任何AnchorChanges 制作动画。这可以通过使用AnchorChanges.target 属性设置特定目标项目来覆盖。

注意: AnchorAnimation 只能在Transition 中与 AnchorChange 结合使用。它不能在行为和其他类型的动画中使用。

另请参阅 Qt QuickAnchorChanges中的动画和过渡

属性文档

duration : int

该属性表示动画的持续时间(毫秒)。

默认值为 250。


easing group

easing.amplitude : real

easing.overshoot : real

easing.period : real

easing.type : enumeration

指定动画使用的缓和曲线

要指定一条缓和曲线,至少需要指定其类型。对于某些曲线,还可以指定振幅、周期和/或过冲。默认的缓和曲线是线性曲线。

AnchorAnimation { easing.type: Easing.InOutQuad }

有关不同类型缓和曲线的信息,请参阅PropertyAnimation::easing.type 文档。


targets : list<Item> [read-only]

要重新锚定的项目。

如果没有指定目标,所有AnchorChanges 都将通过AnchorAnimation 进行动画。


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.