Details
-
Task
-
Resolution: Invalid
-
P2: Important
-
None
Description
We would like to define models with types, so that we can statically compile them to C++. A proposal for the syntax would be:
// ElementWithModel.qml Item { id: root component DataItem { property string city; property real shift; } property Model<DataItem> model; } // Instance.qml Item { ElementWithModel { model: Model<DataItem> { DataItem { city: "x" shift: 0.5 } DataItem { city: "x" shift: 0.5 } } } } // InstanceWithShorthand.qml Item { ElementWithModel { model: [ { city: "x", shift: 0.5, }, { city: "x" shift: 0.5 } ] } } // InstanceWithRepeater.qml (for mock data) Item { ElementWithModel { model: { Repeater<DataItem> { model: 25 DataItem { city: "x" + modelData shift: modelData } } } } } // Window with shorthand for Items (doesn't make much sense) Window { [ { x: 5, y: 6 }, { x: 30, y: 7 } ] }
This code would be simpler and easier to read when using inline components. In addition the typed model data can be used to verify the compatibility against delegates with required properties.
Attachments
Issue Links
- is required for
-
QTBUG-73675 Streamline QML for better toolability and performance
- Open
- relates to
-
QTBUG-82443 Value types and Containers in QML
- Closed
-
QTBUG-69574 QML Basic Type "list" - Add pop()
- Closed
-
QTBUG-81241 Support javascript functions from javascript array model to delegates
- Closed