Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Scale will not reset if inside a State 'PropertyChanges'
Forum Updated to NodeBB v4.3 + New Features

Scale will not reset if inside a State 'PropertyChanges'

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xsacha
    wrote on last edited by
    #1

    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.

    • Sacha
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xsacha
        wrote on last edited by
        #3

        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)@

        • Sacha
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved