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. State doesn't restore original state

State doesn't restore original state

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 327 Views 2 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.
  • DuBuD Offline
    DuBuD Offline
    DuBu
    wrote on last edited by
    #1

    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?

    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