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] Transition in a row works only once.
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Transition in a row works only once.

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 931 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.
  • M Offline
    M Offline
    matteli
    wrote on last edited by
    #1

    Hi all,

    Here the code :
    @
    import QtQuick 2.0

    Rectangle {
    width: 200
    height: 50
    Row {
    id: row
    spacing: 2

        Rectangle { id: rect1; color: "green"; width: 50; height: 50}
        Rectangle { id: rect2; color: "blue"; width: 50; height: 50}
        Rectangle { id: rect3; color: "red"; width: 50; height: 50;
        MouseArea {
                anchors.fill: parent
                onClicked: {
                    if (row.state == "one")
                        row.state = "all"
                    else
                        row.state = "one"
                }
           }
        }
        state: "one"
        states: [
                State {
                    name: "one"
                    PropertyChanges { target: rect1; visible: false }
                    PropertyChanges { target: rect2; visible: false }
                },
                State {
                    name: "all"
                    PropertyChanges { target: rect1; visible: true }
                    PropertyChanges { target: rect2; visible: true }
                }
            ]
        add: Transition {
                NumberAnimation { property: "x"; duration: 2000; easing.type: Easing.OutBack }
            }
    
        move: Transition {
                NumberAnimation { property: "x"; duration: 2000; easing.type: Easing.OutBack }
            }
    }
    

    }
    @

    The first time i click, no problem, the red, blue and green square take place with a smooth transition.

    When i click again for that the green and blue square disappear, there is a smooth transition for the red but not for the 2 others. So 1st problem, there is a add property for the transition in a row but not a remove property.

    When i click again for that the green and blue become visible again, there is a smooth transition for the red but not for the 2 others. So 2nd problem, the add property for the transition in a row works only the 1st time.

    What do you think of this ? Do you think that i can put that on the bug tracker or is it a normal behavior ?

    Thanks

    matteli

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

      I found a solution :
      @
      import QtQuick 2.0

      Rectangle {
      width: 200
      height: 50
      Row {
      id: row

          Rectangle { id: rect1; color: "green"; height: 50}
          Rectangle { id: rect2; color: "blue"; height: 50}
          Rectangle { id: rect3; color: "red"; width: 50; height: 50;
              MouseArea {
                  anchors.fill: parent
                  onClicked: {
                      if (row.state == "one")
                          row.state = "all"
                      else
                          row.state = "one"
                  }
             }
          }
          state: "one"
          states: [
                  State {
                      name: "one"
                      PropertyChanges { target: row; spacing: 0 }
                      PropertyChanges { target: rect1; width: 0 }
                      PropertyChanges { target: rect2; width: 0 }
                  },
                  State {
                      name: "all"
                      PropertyChanges { target: row; spacing: 10 }
                      PropertyChanges { target: rect1; width: 50 }
                      PropertyChanges { target: rect2; width: 50 }
                  }
              ]
      
          transitions: Transition {
              ParallelAnimation{
                  NumberAnimation { property: "spacing"; duration: 2000; easing.type: Easing.Linear }
                  NumberAnimation { property: "x"; duration: 2000; easing.type: Easing.Linear }
      
                  NumberAnimation { properties: "width"; duration: 2000; easing.type: Easing.Linear }
              }
      
          }
      
      }
      

      }
      @

      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