State doesn't restore original state



  • Hi all,

    I just noticed a bug or a feature when restoring a state after a state change. Here's a simple example:

    Row {
      anchors.fill: parent
      Button {
        id: b1
        text: "hide white+red"
        checkable: true
      }
      Button {
        id: b2
        text: "hide red"
        checkable: true
      }
      Rectangle {
        height: 26
        width: 120
        visible: !b1.checked
        color: "white"
        Rectangle {
          id: rect
          anchors.fill: parent
          anchors.margins: parent.height / 5
          color: "red"
          states: [
            State {
              when: h2.checked
              PropertyChanges { target: rect; visible: false }
            }
          ]
        }
      }
    }
    

    What happens: Both buttons work perfectly pressed on it's own. But when you check and uncheck button "b2" while button "b1" is checked, the red rectangle never appears again.
    I can workaround it by adding the line

    visible: parent.visible
    

    to the red rectangle. But that statement should be the default.
    It also works if I don't use a state and bind the visibility directly like in the white rectangle. But that's just an example, in my real world app I really would like to use the state feature.

    Is this a bug?


Log in to reply
 

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