Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16611

Inconsistent application of PropertyChanges for named and un-named states

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • None
    • Quick: Other
    • None

    Description

      If there are PropertyChanges defined for a named state, and the start state (at construction time) is set to this named state, then when constructed the state of the element will be as defined by said PropertyChanges. However, if the default un-named state has PropertyChanges defined, and this un-named state is the elements state at construction, then the PropertyChanges in the un-named state are not applied. Yet when some time later switching from the named to the un-named state the un-names state's PropertyChanges are applied (I believe).

      [later: added an example showing the issue]
      Run the code below and note how the rectangle start out blue because the state as been explicitly set to "foo" and the foo state has a PropertyChanges setting the rect's color to blue:

      import QtQuick 1.0
      
      Item {
          width: 640
          height: 480
      
          Rectangle {
              id: rect
              color: "yellow"
              width: 100
              height: 100
              anchors.centerIn: parent
          }
      
          state: "foo" // change "foo" to ""
          states: [
              State {
                  name: ""
                  PropertyChanges { target: rect; color: "red"; }
              },
              State {
                  name: "foo"
                  PropertyChanges { target: rect; color: "blue"; }
              }
          ]
      
          MouseArea {
              anchors.fill: parent
              onClicked: parent.state = (parent.state == "" ? "foo" : "")
          }
      }
      

      Now change the initial state from "foo" to "" and note how the rectangle start out yellow rather than red as defined in the un-named state's PropertyChanges. I.e. when the initial state is a named state the PropertyChanges defined by that state is applied at construction, but the same is not true for an un-named initial state.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes