- Qt 6.11
- QML Types
- QtQml.Models
- FunctionFilter
- Qt 6.11.0 Reference Documentation

# FunctionFilter QML Type

Filters data in a SortFilterProxyModel based on the evaluation of the designated 'filter' method. More...

Import Statement: | `import QtQml.Models`
Since: | Qt 6.10
Inherits: | Filter
Status: | Preliminary

This type is under development and is subject to change.

- List of all members, including inherited members

## Detailed Description

FunctionFilter allows user to define the designated 'filter' method and it will be evaluated to filter the data. The 'filter' method takes one argument and it can be defined as inline component as below:

     SortFilterProxyModel {
         model: sourceModel
         filters: [
             FunctionFilter {
                 id: functionFilter
                 property int ageLimit: 20
                 component RoleData: QtObject {
                     property real age
                 }
                 function filter(data: RoleData) : bool {
                     return (data.age <= ageLimit)
                 }
             }
         ]
     }

Note: The user needs to explicitly invoke SortFilterProxyModel::invalidate whenever any external qml property used within the designated 'filter' method changes. This behaviour is subject to change in the future, like implicit invalidation and thus the user doesn't need to explicitly invoke SortFilterProxyModel::invalidate.