ValueFilter QML Type

根据角色名称和值过滤SortFilterProxyModel 中的数据。更多

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

RoleFilter

Status: Preliminary

此类型正在开发中,可能会有更改。

属性

详细说明

ValueFilter 允许用户根据源模型中配置的角色名称或指定值或两者过滤数据。用于过滤数据的角色名称应基于模型role name 。角色名的默认值是"display"

下面的代码段展示了如何使用 ValueFilter 仅包含源模型中的数据,其中角色名"favorite" 的值为"true"

SortFilterProxyModel {
    model: sourceModel
    filters: [
        ValueFilter {
            roleName: "favorite"
            value: true
        }
    ]
}

属性文档

value : string

该属性包含可用于过滤数据的特定值。

默认值为空字符串。


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