FunctionFilter QML Type
根据对指定“filter”方法的评估,对SortFilterProxyModel 中的数据进行过滤。更多内容...
| Import Statement: | import QtQml.Models |
| Since: | Qt 6.10 |
| Inherits: | |
| Status: | Technology preview |
此类型处于技术预览阶段,可能会有变动。
详细说明
FunctionFilter 允许用户定义指定的“filter”方法,系统将对其进行求值以过滤数据。“filter”方法接受一个参数,并可如下所示定义为内联组件:
SortFilterProxyModel {
sourceModel: model
filters: [
FunctionFilter {
id: functionFilter
property int ageLimit: 20
function filter(age: int) : bool {
return (age <= ageLimit)
}
}
]
}注意: 当指定“filter”方法中使用的任何外部 QML 属性发生变化时,用户 需要显式调用 `SortFilterProxyModel::invalidate `。此行为未来可能会发生变化(例如采用隐式失效机制),届时用户将无需显式调用 `SortFilterProxyModel::invalidate`。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.