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

Assigning to array elements of QQmlListProperty in QML has no effect

XMLWordPrintable

      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.

        1. listassign.zip
          227 kB
          Mark Visser
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes