FunctionFilter QML Type

지정된 '필터' 방법의 평가에 따라 SortFilterProxyModel 에서 데이터를 필터링합니다. 더 보기...

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

Filter

Status: Preliminary

이 유형은 개발 중이며 변경될 수 있습니다.

상세 설명

FunctionFilter를 사용하면 사용자가 지정된 '필터' 메서드를 정의할 수 있으며, 이 메서드가 데이터를 필터링하기 위해 평가됩니다. '필터' 메서드는 하나의 인수를 받으며, 아래와 같이 인라인 컴포넌트로 정의할 수 있습니다:

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

참고: 사용자는 지정된 '필터' 메서드 내에서 사용되는 외부 qml 속성이 변경될 때마다 SortFilterProxyModel::invalidate 을 명시적으로 호출해야 합니다. 이 동작은 암시적 무효화와 같이 향후 변경될 수 있으므로 사용자가 SortFilterProxyModel::invalidate 을 명시적으로 호출할 필요는 없습니다.

© 2025 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.