[SOLVED] AnchorChanges strange effect
Hello.
- import QtQuick 1.1
- Rectangle {
- id: rect
- width: 300; height: 200
- focus: true
- Keys.onDigit1Pressed: rect.state = "state1"
- Keys.onDigit0Pressed: rect.state = ""
- state: "state1"
- Text { id: textItem }
- onColorChanged: textItem.text += "new color " + rect.color + "\n"
- states: [
- State {
- name: "state1";
- PropertyChanges { target: rect; color: "lightgrey" }
- AnchorChanges { target: textItem; anchors.left: rect.left }
- }
- ]
- }
This program prints
new color #d3d3d3
new color #ffffff
new color #d3d3d3
With AnchorChanges commented it prints
new color #d3d3d3
So property is changed one time upon entering a state, but with AnchorChanges it is changed three times forth and back.
What’s wrong here?
I try on windows (mingw).
2 replies
This is due to state fast forwarding, see http://qt-project.org/doc/qt-4.8/qdeclarativestates.html#state-fast-forwarding for more details on what is happening behind the scenes and why.
Regards,
Michael
You must log in to post a reply. Not a member yet? Register here!


