本页内容

RangeFilter QML Type

通过检测角色值是否在给定范围内,对SortFilterProxyModel 中的数据进行筛选。更多内容...

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

RoleFilter

Status: Technology preview

此类型处于技术预览阶段,可能会有变动。

属性

方法

详细说明

RangeFilter 接受配置的角色值介于minimum 和maximum 之间的行。默认情况下,这两个边界值均包含在内。

以下示例展示了 CPU 使用率在 70 到 100 之间的进程:

SortFilterProxyModel {
    sourceModel: processModel
    filters: [
        RangeFilter {
            roleName: "cpuUsage"
            minimum: 70
            maximum: 100
        }
    ]
}

当边界值本身不应被包含在内时,请使用exclusive():

RangeFilter {
    roleName: "cpuUsage"
    minimum: exclusive(70)
    maximum: 100
}

属性文档

maximum : variant

该范围的上限。角色值大于该值的行将被排除。若未设置,则无上限。

指定一个整数值将使该范围包含边界值——即值等于maximum 的行也将被接受。若要排除边界值本身,请使用exclusive()。

minimum : variant

该范围的下限。角色值小于此值的行将被排除。若未设置,则无下限。

指定一个普通数值会使该边界包含该值——即值等于minimum 的行会被接受。若要排除边界值本身,请使用exclusive()。

方法文档

variant exclusive(value)

返回一个从范围中排除value 的边界。角色值等于value 的行将被拒绝。

RangeFilter {
    roleName: "score"
    minimum: 0
    maximum: RangeFilter.exclusive(100)

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