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

Required properties of delegates are null when not using "var"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 6.2.1
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      Linux/X11

      Description

      When using delegates with "required" properties, instead of relying on context properties, and a property is a QML type, the property is null if the propert type is used. If one uses "var", the property will be set correctly:

       

      component TestItem : QtObject {
      
      }
      Component {
       id: component
       TestItem {
        property string text: "hello!!"
       }
      }
      ListView {
       id: list
       anchors.fill: parent
       delegate: Text {
        // if type is changed to 'var', it works!! Otherwise 'item' stays null!?
        required property TestItem item
        text: item.text
        height: 100
       }
       model: ListModel {
        id: testModel
       }
       Component.onCompleted: {
        testModel.append({ item: component.createObject(null, {}) })
       }
      } 
      

       

       

        Attachments

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

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            jschaubzes Johannes Schaub
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes