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

Overriding QQmlListProperty in QML appends instead of replacing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 6.0
    • 5.2.1, 5.3.2, 5.4.2, 5.5.1, 5.6.3, 5.7.1, 5.8.0, 5.9.3, 5.10.1, 5.11.3, 5.12.4, 5.13.0
    • All
    • 1876bd4215ccf5bbaa6f571177db889ba4bc8eff (qt/qtdeclarative/dev)

      If I create a class with a QQmlListProperty and then initialise it with an array in some QML file, then subclass the QML type in a second QML file and try to override the array there, when creating an instance of the child class, the list contains the arrays concatenated instead of the overriding array.
      In the attached example, I would expect the list to contain 2 elements instead of 5.
       
      We should make the list replace behavior configurable on a class-by-class base. A Q_CLASSINFO("QML.ListReplaceBehavior", ...) could be added for that. The options would be "AlwaysAppend", "AppendIfDefaultProperty", "Replace". See comments on https://codereview.qt-project.org/c/qt/qtdeclarative/+/280328 . In Qt6 we can actually break binary compatibility. So, adding a property to the list itself is feasible, if it makes sense.

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

            unai_i Unai IRIGOYEN
            unai_i Unai IRIGOYEN
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes