This looks like a bug. changes can either be a list of inline Change elements, or a list accessed by id or a property. The error message changes depending on the order. With an id first, it complains about missing a , for inline elements. With an inline element first, it complains about a missing { for ids.
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
MouseArea { anchors.fill: parent; onClicked: text.nextState() }
Text {
id: text
anchors.centerIn: parent
text: "click to change"
PropertyChanges { id: a; target: text; color: 'red' }
PropertyChanges { id: b; target: text; text: "State B" }
state: "a"
states: [
State {
name: "a"
changes: [
PropertyChanges { target: text; text: "State A" },
PropertyChanges { target: text; color: "blue" }
]
},
State {
name: "b"
changes: [ a, b ]
},
State {
name: "c"
// The next line causes a syntax error
changes: [ PropertyChanges{ target: text; text: "State C" }, a ]
}
]
function nextState() {
for (var i = 0; i < states.length; i++) {
if (state === states[i].name) {
state = states[(i + 1) % states.length].name;
return;
}
}
}
}
}
That said, I don't think I have ever seen a code base attempt to reuse a PropertyChange in this way. Organizing into base states that contain the common changes, and extended states that customize is usually the way it's done. With a *Change inline in a State, there no need to even mention changes