Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
4.7.1
-
None
Description
When using a declared bool property in a QML component. When changing between two states which uses a PropertyChanges that sets the boolean value as well as changes the geometry of a component, the value will be changed 3 times when being set false.
Given the following example code, When pressing the "M" key the state will be changed. When the MENU_OPEN state is active, onMenuHighlightedChanged will be called once. However when changing to state MENU_CLOSED, onMenuHighlightedChanged will be called 3 times. If you comment out the changes made to anchors.leftMargin, then onMenuHighlightedChanged will be called once each way. While the even value is still always correct, this is clearly not the correct behavior.
import Qt 4.7 Rectangle { id: mainRect width: 400 height: 400 color: "grey" Keys.onPressed: { if(event.key == Qt.Key_M) { if(onScreenMenu.state == "MENU_CLOSED") onScreenMenu.state = "MENU_OPEN"; else onScreenMenu.state = "MENU_CLOSED"; } } focus: true Rectangle { id: onScreenMenu property bool menuHighlighted height: 375; width: 250; color: "#50FFFFFF"; anchors.left: mainRect.left; anchors.verticalCenter: mainRect.verticalCenter; radius: 10; state: "MENU_OPEN"; onMenuHighlightedChanged: { console.log("OnScreenMenu::onMenuHighlightedChanged: menuHighlighted is now : " + menuHighlighted) } states: [ State { name: "MENU_OPEN" PropertyChanges { target: onScreenMenu anchors.leftMargin: 0; menuHighlighted: true; } }, State { name: "MENU_CLOSED" PropertyChanges { target: onScreenMenu anchors.leftMargin: -onScreenMenu.width; menuHighlighted: false; } } ] // transitions: [ // Transition { // from: "MENU_OPEN" // to: "MENU_CLOSED" // reversible: true // NumberAnimation { target: onScreenMenu; property: "anchors.leftMargin"; duration: 500 } // } // ] } }