SequentialAnimation QML Type
允许动画依次运行。更多...
| Import Statement: | import QtQuick |
| Inherits: |
详细说明
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 示例——动画》。
© 2026 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.