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

Required properties break model data injection into delegate objects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.1
    • None
    • any

    Description

      Using a required property appears to break model data injection inside delegate objects:

        component Node : ListView {
          required property ListView owner
        }
      
        Node {
          id: rn
          owner: null
          model: 1
          delegate: Node {
            id: l1
            owner: rn
            model: 1
            property int ii: index
            property int dd: modelData
            delegate: Node {
              owner: l1
              model: 1
              property int ii: index
              property int dd: modelData
              delegate: Text { text: index + " " + modelData }
            }
          }
        }
      

      The result is index and modelData cannot be resolved for any but the innermost view.

      qrc:/main.qml:30: ReferenceError: modelData is not defined
      qrc:/main.qml:29: ReferenceError: index is not defined
      qrc:/main.qml:25: ReferenceError: modelData is not defined
      qrc:/main.qml:24: ReferenceError: index is not defined

      Simply omitting the `required` keyword produces a runtime with no errors.

      Additionally, nesting each subsequent Node inside any qml object instance (not Component tho) also appears to "fix" it and everything is resolved properly:

        Node {
          id: rn
          owner: null
          model: 1
          delegate: Row { Node {
            id: l1
            owner: rn
            model: 1
            property int ii: index
            property int dd: modelData
            delegate: Row { Node {
              owner: l1
              model: 1
              property int ii: index
              property int dd: modelData
              delegate: Text { text: index + " " + modelData }
            } }
          } }
        }
      

      The above snipped does work with required property.

      This time the problem is not related to inline components, it is the same if Node is defined in its own source.

      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
            dgo dgo
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes