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

[Reg 5.15 -> 6.2] QML Binding is overwritten after initialization

    XMLWordPrintable

Details

    • All
    • c9d7620bc (dev), bd75b606c (6.8), 3b4ec8930 (6.7), ed3a38733 (tqtc/lts-6.5), b0a0eb700 (tqtc/lts-6.2)

    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

            ulherman Ulf Hermann
            julianc Julian Albrecht
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: