FunctionSorter QML Type

指定された'ソート'メソッドの評価に基づいて、SortFilterProxyModel のデータをソートする。さらに...

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

Sorter

Status: Preliminary

この型は開発中であり、変更される可能性がある。

詳細説明

FunctionSorter は、ユーザが指定した 'sort' メソッドを定義し、それが評価されてデータがソートされるようにする。このメソッドは、指定されたパラメータ型の2つの引数(lhsとrhs)を取り、以下のようにデータにアクセスして評価することができます、

SortFilterProxyModel {
    model: sourceModel
    sorters: [
        FunctionSorter {
            id: functionSorter
            component RoleData: QtObject {
                property real age
            }
            function sort(lhsData: RoleData, rhsData: RoleData) : int {
                return (lhsData.age < rhsData.age) ? -1 : ((lhsData === rhsData.age) ? 0 : 1)
            }
        }
    ]
}

注意: 指定された 'sort' メソッド内で使用される外部 qml プロパティが変更されるたびに、ユーザーは明示的にSortFilterProxyModel::invalidateSorter を呼び出す必要があります。この動作は暗黙の無効化のように将来変更される可能性があるため、ユーザーは明示的にSortFilterProxyModel::invalidateSorter を呼び出す必要はありません。

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