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

QtQuick compiler and QML States/AnchorChanges at loading prevents component to be displayed

XMLWordPrintable

    • All
    • dd86881520dde6c1487e5397f10b82584e6b9eaa (qt/qtdeclarative/dev) aea1336f9e7be7e85d2286b2a388341fda6b61ae (qt/qtdeclarative/6.2)

      When building a QML project using Qt Quick compiler, if an AnchorChanges is applied when the component is loading, it just does not appear at all.

      import QtQuick 2.12
      
      ApplicationWindow {
          width: 1280
          height: 720
      
          Rectangle {
              id: rectangle
              width: parent.width * 0.2
              height: parent.height
              anchors.right: parent.right
              color: "red"
              state: "closed"
              states: [
                  State {
                      name: "closed"
                      AnchorChanges { target: rectangle; anchors.right: undefined; anchors.left: parent.right }
                  }
              ]
          }
      
          MouseArea {
              anchors.fill: parent
              onClicked: rectangle.state = (rectangle.state == "closed" ? "" : "closed")
          }
      }

      In this example, the Rectangle is by default attached to the right of the screen, and a click hides it. Applying the "closed" state to the rectangle at loading prevents it to be displayed. 

      It works fine without the QtQuick compiler, and it works fine when removing the "state: "closed"" line. 

       

        For Gerrit Dashboard: QTBUG-91165
        # Subject Branch Project Status CR V

            fabiankosmale Fabian Kosmale
            v.yolteotl Valentin Offner
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes