Reputation: 33
I have a QRect which I try to filter in qml using RegExpFilter QRect(1220,50, 500, 300)
I want to match them like that: QRect([0-2000], [0-500], *, *)
SortFilterProxyModel
{
onCountChanged: listView.recalculate()
id: proxyModel
sourceModel: m_sourceModel
filters: [
RegExpFilter {
enabled: true
roleName: "myQRectRole"
pattern: ????
}
]
}
I am stuck as it is a QRect, is it even possible?
(using SortFilterProxyModel and RegExpFilter)
Upvotes: 2
Views: 111
Reputation: 244282
RegExpFilter only serves to filter strings, in your case it is not. The solution is use ExpressionFilter:
SortFilterProxyModel {
id: proxyModel
sourceModel: m_sourceModel
filters: [
ExpressionFilter{
// QRect([0-2000], [0-500], *, *)
expression: (model.myQRectRole.x >= 0 && model.myQRectRole.x <= 2000) && (model.myQRectRole.y >= 0 && model.myQRectRole.y <= 500)
}
]
}
In the following link there is an example.
Upvotes: 3