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

Using StackView.Immediate with an OpacityAnimator in the transition causes the StackView to use the transition's `from` values instead of `to` values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.2
    • Quick: Controls 2
    • None
    • Operating System: openSUSE Tumbleweed 20230926
      Qt Version: 6.5.2
    • Linux/X11

    Description

      Run the following code. First press the "Push" button. Both var1 and var2 correctly transition from 0 to 1. The opacity of stackView2 transitions from 0 to 1.

      Then press the "Push (Immediate)" button. var1 is instantly set to 1. var2 and stackView2.opacity are instantly set to 0. I believe the correct behaviour should be stackView2.opacity === 1 and var2 === 1.

       

      import QtQuick
      import QtQuick.Controls as Controls
      Controls.ApplicationWindow {
          id: root
          width: 800
          height: 600
          visible: true
          property real var1: -1
          property real var2: -1
          readonly property int transitionDuration: 500
          Component {
              id: myComponent
              Rectangle {}
          }
          Column {
              anchors.verticalCenter: parent.verticalCenter
              Controls.Button {
                  text: "Push"
                  onClicked: {
                      stackView1.push(null, myComponent, {color: "red"})
                      stackView2.push(null, myComponent, {color: "red"})
                  }
              }
              Controls.Button {
                  text: "Push (immmediate)"
                  onClicked: {
                      stackView1.push(null, myComponent, {color: "blue"}, Controls.StackView.Immediate)
                      stackView2.push(null, myComponent, {color: "blue"}, Controls.StackView.Immediate)
                  }
              }
              Controls.Button {
                  text: "Clear"
                  onClicked: {
                      stackView1.clear()
                      root.var1 = -1
                      stackView2.clear()
                      root.var2 = -1
                  }
              }
              Controls.Label {
                  text: "StackView1 items: " + stackView1.depth + ", current opacity: " + stackView1.currentItem?.opacity + ", var1: " + root.var1
              }
              Controls.Label {
                  text: "StackView2 items: " + stackView2.depth + ", current opacity: " + stackView2.currentItem?.opacity + ", var2: " + root.var2
              }
              Controls.StackView {
                  id: stackView1
                  width: 50
                  height: 50
                  initialItem: Rectangle {color: "green"}
                  pushEnter: Transition {
                      NumberAnimation {
                          from: 0
                          to: 1
                          duration: root.transitionDuration
                          target: root
                          property: "var1"
                      }
                  }
              }
              Controls.StackView {
                  id: stackView2
                  width: 50
                  height: 50
                  initialItem: Rectangle {color: "green"}
                  pushEnter: Transition {
                      NumberAnimation {
                          from: 0
                          to: 1
                          duration: root.transitionDuration
                          target: root
                          property: "var2"
                      }
                      OpacityAnimator {
                           from: 0
                           to: 1
                           duration: root.transitionDuration
                       }
                   }
              }
          }
      }
       

       

       

      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
            jackh Jack Hill
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes