Details
-
Task
-
Resolution: Done
-
P2: Important
-
None
-
d621027babff9a30d56ab6af871a465108c9eaba (qt/qtdeclarative/dev)
Description
At the moment all available sequence types are registered from qv4sequenceobject.cpp.
qv4sequenceobject.cpp produces the largest single piece of binary code in Qt QML. It registers a variety of C++ containers as sequence objects to V4. For each combination of container and item type a few accessor functions have to be generated, leading to combinatorial explosion. In particular, the following types are registered:
// F(elementType, elementTypeName, sequenceType, defaultValue) #define FOREACH_QML_SEQUENCE_TYPE(F) \ F(int, IntVector, QVector<int>, 0) \ F(qreal, RealVector, QVector<qreal>, 0.0) \ F(bool, BoolVector, QVector<bool>, false) \ F(int, IntStdVector, std::vector<int>, 0) \ F(qreal, RealStdVector, std::vector<qreal>, 0.0) \ F(bool, BoolStdVector, std::vector<bool>, false) \ F(int, Int, QList<int>, 0) \ F(qreal, Real, QList<qreal>, 0.0) \ F(bool, Bool, QList<bool>, false) \ F(QString, String, QList<QString>, QString()) \ F(QString, QString, QStringList, QString()) \ F(QString, StringVector, QVector<QString>, QString()) \ F(QString, StringStdVector, std::vector<QString>, QString()) \ F(QUrl, Url, QList<QUrl>, QUrl()) \ F(QUrl, UrlVector, QVector<QUrl>, QUrl()) \ F(QUrl, UrlStdVector, std::vector<QUrl>, QUrl()) \ F(QModelIndex, QModelIndex, QModelIndexList, QModelIndex()) \ F(QModelIndex, QModelIndexVector, QVector<QModelIndex>, QModelIndex()) \ F(QModelIndex, QModelIndexStdVector, std::vector<QModelIndex>, QModelIndex()) \ F(QItemSelectionRange, QItemSelectionRange, QItemSelection, QItemSelectionRange())
Quite obviously, this list is rather arbitrary. Hardly anyone will use all of those, but some rather common ones are missing. For example there is no real reason why you wouldn't be able to pass a QList<QColor>.
The fix to this involves three measures:
- Add public API to register your own container types as sequence objects via a template.
- Add a convenience wrapper around that to allow registering all the currently pre-registered sequence objects in one line in Qt6.
- Drop the pre-registering in Qt6.
Attachments
Issue Links
- is duplicated by
-
QTBUG-75480 QML/C++ Conversions: Support more Lists, Maps and Hashes without QVariant
- Closed
- relates to
-
QTBUG-68796 Create plugin.qmltypes automatically at build time
- Closed
-
QTBUG-79264 Provide a "lightweight model" template to mimic a key/value map
- Closed
-
QTBUG-82443 Value types and Containers in QML
- Closed
-
QTBUG-59971 Standard Library Type Support for QtQML
- Closed
-
QTBUG-73399 Make it possible to use containered Q_GADGETS in QML
- Closed
-
QTBUG-79263 Provide a replace function for QQmlListProperty
- Closed
- split to
-
QTBUG-121752 Add a way to register associative containers of object or value types
- Reported