SequentialAnimation QML Type

允许按顺序运行动画。更多

Import Statement: import QtQuick
Inherits:

Animation

详细说明

SequentialAnimation 和ParallelAnimation 类型允许同时运行多个动画。在 SequentialAnimation 中定义的动画会一个接一个地运行,而在ParallelAnimation 中定义的动画会同时运行。

下面的示例按顺序运行了两个数字动画。Rectangle 先运行x 位置为 50 的动画,然后运行y 位置为 50 的动画。

import QtQuick

Rectangle {
    id: rect
    width: 100; height: 100
    color: "red"

    SequentialAnimation {
        running: true
        NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 }
        NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 }
    }
}

Transition 中定义的动画会自动并行运行,因此如果希望这样做,可以使用 SequentialAnimation 将动画封装在Transition 中。

与其他动画类型一样,SequentialAnimation 可以多种方式应用,包括过渡、行为和属性值源。 Qt Quick 文档 中的动画和过渡显示了多种创建动画的方法。

注: 一旦动画被分组为 SequentialAnimation 或ParallelAnimation ,就不能单独启动和停止;必须将 SequentialAnimation 或ParallelAnimation 作为一个组来启动和停止。

另请参阅 ParallelAnimation Qt Quick 中的动画和过渡,以及Qt Quick 示例 - 动画

© 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.