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

QML Binding is overwritten after initialization

    XMLWordPrintable

Details

    • All

    Description

      Normally I would expect that changing the height of the width from the outside would also overwrite the internal binding. But in this case, the internal binding intervenes and the height and width are exceeded again.

      Main.qml

      import QtQuickWindow {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello Binding")
          SimpleWidget {
              width: 20
              height: 400
          }
      }
       

      SimpleWidget.qml

      import QtQuickItem {
          id: outer
          Rectangle {
              id: inner
              color: "green"
              width: style.width
              height: style.height
          }
      
          width: inner.width
          height: inner.height
      
          onWidthChanged: {
              if (width !== inner.width) {
                  inner.width = width #overwrite binding
              }
          }
          onHeightChanged: {
              if (height !== inner.height) {
                  inner.height = height #overwrite binding
              }
          }
          QtObject {
              id: style
              property int width: 50
              property int height: 50
          }
      }
      

      Logging of size changes from the inner Rectangle:
      qml: inner rectangle height change: 400
      qml: inner rectangle width change: 20
      qml: inner rectangle height change: 50
      qml: inner rectangle width change: 50

      It feels a little bit like QTBUG-122962

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            julianc Julian Albrecht
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes