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

QML Repeater and Instantiator should be allowed to create items for DefaultProperty list properties

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • None

    Description

      QML Repeater is very useful for creating items, and Instantiator for creating objects. It would be nice if these could be used to create elements that are passed to a DefaultProperty declared list of items or objects.

      ItemWithDefaultListProperty {
          Instantiator {
              model: 3
              CustomElement { }
          }
      }

      Given this C++ header:

      class ItemWithDefaultListProperty : public QQuickItem
      {
          Q_PROPERTY(QQmlListProperty<CustomElement> elements READ elements)
          Q_CLASSINFO("DefaultProperty", "elements")
          Q_OBJECT
      public:
      ...

      The issue is that when using an instantiator in this way, the instantiator itselfs is assigned to the default property, instead of the elements it creates. So the resulting QML syntax error is one of wrong type assignment...

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            andrhans Andreas Aardal Hanssen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes