December 17, 2010

xsacha xsacha
Lab Rat
517 posts

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:

  1. 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:

  1. 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:

  1. 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.

 Signature 

- Sacha

2 replies

December 17, 2010

mbrasser mbrasser
Lab Rat
452 posts

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

December 17, 2010

xsacha xsacha
Lab Rat
517 posts

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:

  1. grid.model.move(grid.currentIndexDrag, index, 1)
  2. grid.currentIndexDrag = index

The update to the variable comes too late I guess.

Edit: This doesn’t fix the issue either

  1. grid.model.move(grid.currentIndexDrag, grid.currentIndexDrag = index, 1)

 Signature 

- Sacha

 
  ‹‹ [Solved] Moving to Production from qmlviewer. Why am I so slow?      Behavior element has no ’parent’ property ››

You must log in to post a reply. Not a member yet? Register here!