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

Add support for QQmlListProperty<QQmlComponent>

    XMLWordPrintable

Details

    Description

      Currently in a class derived from QQuickItem I can declare a delegate property like that:

      Q_PROPERTY(QQmlComponent delegate READ delegate ...)
      Q_CLASSINFO("DefaultProperty", "delegate")
      

      and apply a Text component in QML like that:

      MyClass {
        Text {
        }
      }

      Now I want to add another Text component to my item class like so:

      MyClass {
        Text {
        }
        Text {
        }
      }
      

      therefore I change my class to:

      Q_PROPERTY(QQmlListProperty<QQmlComponent> delegates READ delegates ...)
      Q_CLASSINFO("DefaultProperty", "delegates")
      

      But now I get an runtime error saying that it's not possible to apply an object to my property. (Sorry I don't have the correct error message at hand.)

      I don't need the instantiated objects in my list, I need the components to instantiate the actual objects in code.

      Would it be possible to support multiple delegates that way?

      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
            stephaneichler Stephan Eichler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes