在QML中动态地将PropertyChanges添加到State

时间:2017-12-28 17:09:33

标签: qt qml qt5

是否可以将属性更改扩展或动态添加到qml状态?

例如

Item {
    id: myItem;
    state: "opened";

    states: [
        State {
            name: "opened";

            PropertyChanges {
                target: myItem;
                height: 100;
            }
        },
        State {
            name: "closed";

            PropertyChanges {
                target: myItem;
                height: 10;
            }
        }
    ]
}

但后来我希望能够向PropertyChanges添加任何其他属性,例如颜色,宽度,不透明度等。动态。 “结果”看起来像这样

State {
    name: "closed";

    PropertyChanges {
        target: myItem;
        height: 10;
        color: "red";
        width: 10;
        opacity: 0.5;
    }
}

0 个答案:

没有答案