En esta página

FunctionFilter QML Type

Filtra los datos en un SortFilterProxyModel basándose en la evaluación del método 'filter' designado. Más...

Import Statement: import QtQml.Models
Since: Qt 6.10
Inherits:

Filter

Status: Preliminary

Este tipo está en desarrollo y está sujeto a cambios.

Descripción detallada

FunctionFilter permite al usuario definir el método 'filter' designado, que se evaluará para filtrar los datos. El método "filter" toma un argumento y puede definirse como componente en línea, tal como se indica a continuación:

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)
            }
        }
    ]
}

Nota: El usuario debe invocar explícitamente SortFilterProxyModel::invalidate cada vez que cambie una propiedad qml externa utilizada en el método "filter" designado. Este comportamiento está sujeto a cambios en el futuro, como la invalidación implícita, por lo que el usuario no necesita invocar explícitamente 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.