I have several states which I use only to change some properties:
Item {
id: props
property int someProperty: 0
// ...
states: [
State {
name: "firstState"
PropertyChange {
target: props
someProperty: 1
// ...
}
},
State {
name: "secondState"
PropertyChange {
target: props
someProperty: 1
// ...
}
}
]
onStateChange: doSomething(someProperty)
}
Since different states could have the same value for someProperty I can't rely on the somePropertyChange signal, but I can't even rely on the onStateChange (as in the example) since when it runs the properties are unchanged.
So how could I run doSomething() every time the state change? There is a better way to do this kind of things with QML?
doSomething()everywhere doesn't sound like a good choice (but I could create a function that change state and rundoSomething()instead of changing the value of state). In the real applicationsomePropertyis the number of seconds after which an event should be triggered, if the state change the timer should start from the beginning (if two states have the same number of seconds thesomePropertyChangesignal is not fired so the timer doesn't restart by using a property binding).runningproperty fromTimercomponent.Timerwhen the state change even if the value of the seconds is exactly the same.