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

"Required property foo was not initialized" when using JS array as model with required properties in delegate

    XMLWordPrintable

Details

    • 4dbd70b5a (dev)

    Description

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Layouts
      
      ApplicationWindow {
          width: 800
          height: 800
          visible: true
      
          Repeater {
              // Doesn't work:
              model: [
                  { displayName: "None", roundedScale: 0 },
                  { displayName: "ExtraSmall", roundedScale: 1 },
                  { displayName: "Small", roundedScale: 2 },
                  { displayName: "Medium", roundedScale: 3 },
                  { displayName: "Large", roundedScale: 4 },
                  { displayName: "ExtraLarge", roundedScale: 5 },
                  { displayName: "Full", roundedScale: 6 }
              ]
              // Works:
      //        model: ListModel {
      //            ListElement { displayName: "None"; roundedScale: 0 }
      //            ListElement { displayName: "ExtraSmall"; roundedScale: 1 }
      //            ListElement { displayName: "Small"; roundedScale: 2 }
      //            ListElement { displayName: "Medium"; roundedScale: 3 }
      //            ListElement { displayName: "Large"; roundedScale: 4 }
      //            ListElement { displayName: "ExtraLarge"; roundedScale: 5 }
      //            ListElement { displayName: "Full"; roundedScale: 6 }
      //        }
      
              ColumnLayout {
                  id: scaleLayout
      
                  required property string displayName
                  required property int roundedScale
      
                  Label {
                      text: scaleLayout.displayName
                  }
      
                  Repeater {
                      model: 13
      
                      Button {
                          text: scaleLayout.roundedScale
      
                          Material.elevation: modelData
                      }
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes