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

State transition does not work in Qt6

    XMLWordPrintable

Details

    • Linux/X11

    Description

      The following code works fine in Qt5, however fails in Qt6:

      SettingsPanel.qml:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      
      Rectangle {
          id: settingsPanel
          x: -width
          width: parent.width / 4
      
          property bool isSlideOut: settingsPanel.state == "slideOut"
      
          Behavior on x { PropertyAnimation {} }
      
          function toggleSlide() {
              if (isSlideOut) {
                  state = "slideIn";
              } else {
                  state = "slideOut"
              }
              return isSlideOut;
          }
      
          states: [
              State {
                  name: "slideOut"
                  PropertyChanges { target: settingsPanel; x: 0 }
              },
              State {
                  name: "slideIn"
                  PropertyChanges { target: settingsPanel; x: -width }
              }
          ]
      }
      

      Main Window has the following code: 

                  Button {
                      checkable: true
                      checked: false
      
                      onCheckedChanged: {
                          settingsPanel.toggleSlide()
                      }
                  }
      
          SettingsPanel {
              id: settingsPanel
              anchors { top: parent.top; bottom: parent.bottom; topMargin: 1 }
          }

       

      Issues observed:

      1. Panel slides in on application start while on start it should be hidden:
        x: -width
      1. On button checked panel slides out, however
      2. On uncheck it does not slides in - x: remains 0.

       

      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
            alekseyka Aleksey Kontsevich
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes