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

Assigning to array elements of QQmlListProperty in QML has no effect

    XMLWordPrintable

Details

    Description

      QQmlListProperty has no accessor for setting an existing element of the exposed array in QML. For example, if "guests" is an exposed QQmlListProperty, the code in Component.onCompleted below has no effect:

      BirthdayParty {
          host: Person {
              name: "Bob Jones"
              shoeSize: 12
          }
      
          guests: [
              Person { name: "Cam Stevens" },
              Person { name: "Janet White" },
              Person { name: "Mahmoud Abdullah" }
          ]
      
          property var leo: Person { name: "Leo Hodges" }
          property var jack: Person { name: "Jack Smith" }
          property var anne: Person { name: "Anne Brown" }
      
          Component.onCompleted: {
              guests[0] = leo;
              guests[1] = jack;
              guests[2] = anne;
          }
      }
      

      This is similar to how writes to an exposed QVariant property are silently discarded, so is at least consistent.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mjmvisser Mark Visser
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: