Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
Description
If there are PropertyChanges defined for a named state, and the start state (at construction time) is set to this named state, then when constructed the state of the element will be as defined by said PropertyChanges. However, if the default un-named state has PropertyChanges defined, and this un-named state is the elements state at construction, then the PropertyChanges in the un-named state are not applied. Yet when some time later switching from the named to the un-named state the un-names state's PropertyChanges are applied (I believe).
[later: added an example showing the issue]
Run the code below and note how the rectangle start out blue because the state as been explicitly set to "foo" and the foo state has a PropertyChanges setting the rect's color to blue:
import QtQuick 1.0 Item { width: 640 height: 480 Rectangle { id: rect color: "yellow" width: 100 height: 100 anchors.centerIn: parent } state: "foo" // change "foo" to "" states: [ State { name: "" PropertyChanges { target: rect; color: "red"; } }, State { name: "foo" PropertyChanges { target: rect; color: "blue"; } } ] MouseArea { anchors.fill: parent onClicked: parent.state = (parent.state == "" ? "foo" : "") } }
Now change the initial state from "foo" to "" and note how the rectangle start out yellow rather than red as defined in the un-named state's PropertyChanges. I.e. when the initial state is a named state the PropertyChanges defined by that state is applied at construction, but the same is not true for an un-named initial state.