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

Binding: short syntax broken with ComponentBehavior: Bound

    XMLWordPrintable

Details

    • a55a85ecc (dev), a1c345490 (6.9), 0b0cb0eea (6.8), 0a285282c (tqtc/lts-6.5)

    Description

      The following code illustrates how the "new" Binding syntax fails to cross component boundaries. Workaround is to use the "old" syntax.

      pragma ComponentBehavior: Bound
      
      import QtQuick
      
      Window {
        id: root
      
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
      
        property int foo
      
        Text {
          text: `Foo: ${root.foo}`
        }
      
        Repeater {
          model: 1
      
          delegate: Item {
            id: delegate
      
            // Error: QML Binding: Unknown name "root.foo". The binding is ignored.
            Binding {
              root.foo: 42
            }
      
            // Works
            // Binding {
            //   target: root
            //   property: "foo"
            //   value: 42
            // }
          }
        }
      }
      

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            njeisecke_qtc Nils Jeisecke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes