Scale will not reset if inside a State 'PropertyChanges'



  • Hey

    For an example reference, look at the first code example in: http://developer.qt.nokia.com/wiki/Drag_and_Drop_within_a_GridView
    On line 18, I have:
    @
    scale: state == "active" ? 0.5 : 1.0 // Can't be placed in state: bug?
    @
    This produces the correct result. The icon scales to 0.5 when state changes to 'active'. Then scales back to normal when state isn't 'active'.

    However, have a look at line 37:

    @PropertyChanges { target: item; x: coords.mouseX - width/2; y: coords.mouseY - height/2 }@

    If I attempt to add scale inside the PropertyChanges instead of changing it manually as shown previously:
    @scale: 0.5@

    Then the scale never resets back to normal.
    All of the other properties such as x and y do reset properly.

    Can anyone explain?

    Thanks.



  • Hi,

    This problem is likely caused by a bad interaction between the Behavior (on the scale) and the State. In the past I've observed cases where a Behavior is mid-animation when the state change occurs, and the state framework remembers the wrong "rewind" value -- I'd guess something like that is happening in this case, though I'm not 100% sure.

    As a workaround, can you animate the scale using a Transition rather than a Behavior?

    Regards,
    Michael



  • Thanks, using a Transition does indeed fix this.

    The transition also seems to generate a lot of lagg when moving items. So I think it is (very quickly) changing state during a move which may be the cause of the original problem.

    As the state relies on the currentIndexDrag variable in here:
    @grid.model.move(grid.currentIndexDrag, index, 1)
    grid.currentIndexDrag = index@
    The update to the variable comes too late I guess.

    Edit: This doesn't fix the issue either
    @grid.model.move(grid.currentIndexDrag, grid.currentIndexDrag = index, 1)@


Log in to reply
 

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