Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.4.0
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:
- a JS array to a QObjectList
- a JS array to something that is qvariant_cast()'able to QSequentialIterable
- a QQmlListProperty<Foo> to QQmlListReference via QmlListWrapper::toListReference()
You can not convert:
- anything to a QQmlListProperty<Foo>, not even for Foo == QObject
- a QList<Foo *> to anything, not even for Foo == QObject
- a QQmlListProperty<Foo> to a QList<Foo *>, not even for Foo == QObject
- 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
- is duplicated by
-
QTBUG-107633 qmlcompiler: recognize QList<T> as signal parameters
- Closed
- resulted from
-
QTBUG-107171 qmlsc: Cannot resolve type annotations for args of type list<T>
- Closed