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

Support for calling methods with lists of objects as arguments is spotty

    XMLWordPrintable

Details

    Description

      Recent experiments (https://codereview.qt-project.org/c/qt/qtdeclarative/+/441261/2) and discussion has shown that our current options of passing lists of objects around are really rather limited.

      You can convert:

      1. a JS array to a QObjectList
      2. a JS array to something that is qvariant_cast()'able to QSequentialIterable
      3. a QQmlListProperty<Foo> to QQmlListReference via QmlListWrapper::toListReference()

      You can not convert:

      1. anything to a QQmlListProperty<Foo>, not even for Foo == QObject
      2. a QList<Foo *> to anything, not even for Foo == QObject
      3. a QQmlListProperty<Foo> to a QList<Foo *>, not even for Foo == QObject
      4. a QQmlListReference to anything

      Now the question is what we want to support. Since the primary list type for object types is QQmlListProperty<Foo>, and that is also auto-registered with each object type, we should strive to support all possible conversions to and from QQmlListProperty<Foo>. Since QQmlListProperty does not own its storage, "conversion" from QList is dangerous and conversion to QList is slow. Conversion to and from QQmlListReference, however, is trivial since QQmlListReference is just a type-erased wrapper around QQmlListProperty. Supporting specific QList<Foo *> as conversion source or target is probably complicated, but supporting QObjectList should be simple.

      The way to go would be to first add support for these conversions to the QML engine, and then add equivalent code to the compilers.

      Attachments

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              ulherman Ulf Hermann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes