ScriptAction QML Type

定义要在动画中运行的脚本。更多

Import Statement: import QtQuick
Inherits:

Animation

属性

详细说明

ScriptAction 可用于在动画中的特定点运行脚本。

SequentialAnimation {
    NumberAnimation {
        // ...
    }
    ScriptAction { script: doSomething(); }
    NumberAnimation {
        // ...
    }
}

作为过渡效果的一部分使用时,您还可以使用scriptName 属性来运行特定的StateChangeScript

State {
    name: "state1"
    StateChangeScript {
        name: "myScript"
        script: doStateStuff();
    }
    // ...
}
// ...
Transition {
    to: "state1"
    SequentialAnimation {
        NumberAnimation { /* ... */ }
        ScriptAction { scriptName: "myScript" }
        NumberAnimation { /* ... */ }
    }
}

另请参阅 StateChangeScript

属性文档

script : script

此属性包含要运行的脚本。


scriptName : string

该属性包含要运行的StateChangeScript 的名称。

该属性仅在ScriptAction 作为过渡的一部分使用时有效。如果同时设置了 script 和 scriptName,则将使用 scriptName。

注意: 在可逆转场中使用 scriptName 时,只有在转场向前运行时才会运行脚本。


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