Proxy model using QML delegate to transform source model. More...
Import Statement: | import QtModelsToolkit . |
This proxy creates object from provided delegate component for every row. The delegate's instance can access data from source model and expose properties as new roles.
ObjectProxyModel may transform not only plain types but also complex types as submodels:
ObjectProxyModel { sourceModel: tokensModel delegate: SortFilterProxyModel { id: delegateRoot readonly property int balancesCount: model.balances.ModelCount.count readonly property int sum: aggregator.value readonly property SortFilterProxyModel balances: this sourceModel: model.balances filters: ExpressionFilter { expression: balance >= thresholdSlider.value } readonly property SumAggregator aggregator: SumAggregator { id: aggregator model: delegateRoot roleName: "balance" } } exposedRoles: ["balances", "balancesCount", "sum"] expectedRoles: ["balances"] }
In this example, submodel "balances" from source model is filtered to keep only values higher or equal to a given threshold. Then it's exposed via "balances" property, overriding original role. Additionally new roles are exposed:
This property holds the component created for every row of the source model in order to transform the source data in-place, overriding existing roles, or/and by exposing new roles.
This property holds the names of roles that are intended to be available within the delegate's instances.
This property holds the names of roles that are exposed from the model. Those names must match names of properties defined in a delegate, as those properties are data source of those roles.