[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).



  • 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



  • Thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.