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

(qmltc) Use QQmlListProperty<QObject> instead of QQmlListReference in generated code

    XMLWordPrintable

    Details

      Description

      Whenever one creates a list<X> property in QML and then assigns something to it via a binding (relevant for QObject * list properties and their assignments), qmltc generates code that creates QQmlListReference and then uses its interface to append elements to the list property.

      This is rather slow* and in reality we could directly use QQmlListProperty<X> API instead (the assumption is that any "list" property in QML is a QQmlListProperty**).

      Rough code generation:

      import QtQuick
      Item { // item has a default property "data" which is a QQmlListProperty
        Text {} // default property assignment here would append to "data"
      }
      
      // rough code generated to assign a Text object:
      
      // old:
      QQmlListReference data(item, "data"); // item is a QQuickItem *
      data.append(text); // text is a QQuickText *
      
      // new:
      QQmlListProperty<QObject> data = item->data(); // call QQuickItem::data() directly
      data.append(&data, text);
      

      * QQmlListReference looks up a property in a QObject by name and then does extra boilerplate that we don't need in qmltc.
      ** except list of value types in which case assume it is a QList but this is out of scope here

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              sami.shalayel Sami Shalayel
              Reporter:
              agolubev Andrei Golubev
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              Fabian Kosmale Fabian Kosmale
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes