diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-07 11:01:56 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-28 15:03:00 +0100 |
commit | b0fc028cb5a5dfa9e95640a32e9b38ca6df0734d (patch) | |
tree | 7a446acca0f5bcbe4e62a1ac22bdb0185913bc5a /src/qml/qml/qqml.h | |
parent | 8c4c0605b077d63e3d73d34ad6dcc4a2cf607b4c (diff) |
QML: Allow named lists of value types
We register QList<T> as sequential container type for any value type T
we get. This way we can always find a type to use for list<t> with t
being a value type. The metatypes are shuffled around so that we have an
easier time associating a type with its list and vice versa.
As QQmlPropertyData's isQList flag denotes both QQmlListProperty<T> and
QList<T> now, we need to use QMetaType::IsQmlList more often.
Conversely, any name given to extra sequential containers registered via
QML_SEQUENTIAL_CONTAINER is explicitly ignored now. As you can do
list<foo> for any type foo now, there is not much of a point in having
further named container registrations for the same type. It would just
make things more complicated. Mind that the name had already been
ignored before, just not explicitly.
[ChangeLog][QtQml] You can now use lists of value types in QML. For
example a property of type list<int> will hold a list of integers.
Task-number: QTBUG-82443
Change-Id: I7bee61cee3963dae5d231bf59f70b8012984371d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r-- | src/qml/qml/qqml.h | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index e205821bbf..b20b8dc5d3 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -843,35 +843,37 @@ inline void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject, const QMetaObject *classInfoMetaObject, const QMetaObject *extensionMetaObject) { - QQmlPrivate::RegisterTypeAndRevisions type = { 1, - QMetaType(), - QMetaType(), - 0, - nullptr, - nullptr, - nullptr, - - uri, - QTypeRevision::fromMajorVersion(versionMajor), - - metaObject, - (classInfoMetaObject ? classInfoMetaObject - : metaObject), - - nullptr, - nullptr, - - -1, - -1, - -1, - - nullptr, - extensionMetaObject, - - &qmlCreateCustomParser<void>, - qmlTypeIds, - -1, - false }; + QQmlPrivate::RegisterTypeAndRevisions type = { + 3, + QMetaType(), + QMetaType(), + 0, + nullptr, + nullptr, + nullptr, + + uri, + QTypeRevision::fromMajorVersion(versionMajor), + + metaObject, + (classInfoMetaObject ? classInfoMetaObject : metaObject), + + nullptr, + nullptr, + + -1, + -1, + -1, + + nullptr, + extensionMetaObject, + + &qmlCreateCustomParser<void>, + qmlTypeIds, + -1, + false, + QMetaSequence() + }; qmlregister(QQmlPrivate::TypeAndRevisionsRegistration, &type); } |