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. [SOLVED] AnchorChanges strange effect
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] AnchorChanges strange effect

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k 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.
  • G Offline
    G Offline
    giovannie
    wrote on last edited by
    #1

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

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

      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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giovannie
        wrote on last edited by
        #3

        Thanks.

        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