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

Regression[5.14->5.15] 'model' is no longer an implicit data role in delegates in Custom delegate

XMLWordPrintable

    • Windows
    • 58cd06033cacadab541efaa16a3eecec37dab0fa (qt/qtdeclarative/dev) 6fe8ed82cdc3e2ec4f6fc9980a41d457b6aed110 (qt/qtdeclarative/6.2) 835955cf8100c7c3381d11b275f62467844d8d7f (qt/tqtc-qtdeclarative/5.15)

      When 'model' is accessed in a custom delegate, it is reported as undefined in 5.15
      As in Example below ImageToggle is custom component, but the property 'isSelected' is not null. It works if 'model' is set as required property or property is set in Component.onCompleted

      // Some comments here
      public String getFoo()
      {    ListView {
              model: myModel
              anchors.fill: parent
              delegate: Row {
                  // Uncomment for this to work under 5.15
                 // required property var model
                  ImageToggle {
                      id: image
                      source: "glyph_16_arrow_patch"
                      isSelected: model.age < 6
                      // Uncomment for this to work under 5.15
                     // Component.onCompleted:isSelected= model.age < 6
                  }
                  Text {
                      text: "age:" + model.age + " selected:" + image.isSelected
                  }
              }
          }
      
          ListModel {
              id: myModel
              ListElement { type: "Cat"; age: 5; }
              ListElement { type: "Dog"; age: 8; }
          }
          return foo;
      }
      

      Code works fine in 5.14.x

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

            fabiankosmale Fabian Kosmale
            shmittal Shveta Mittal
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes