本页内容

StateChangeScript QML Type

指定如何在某个状态下运行脚本。更多内容...

Import Statement: import QtQuick

属性

详细说明

进入某个状态时,会执行 StateChangeScript。您可以选择使用ScriptAction 来指定在状态转换的哪个时间点执行 StateChangeScript。

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

另请参阅 ScriptAction 。

属性文档

name : string

该属性存储脚本的名称。ScriptAction 可以使用该名称来定位特定脚本。

另请参阅 ScriptAction::scriptName 。

script : script

该属性存储了当状态为“当前”时要运行的脚本。

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