FunctionSorter QML Type
Sorts data in a SortFilterProxyModel based on the evaluation of the designated 'sort' method. More...
Import Statement: | import QtQml.Models |
Since: | Qt 6.10 |
Inherits: | |
Status: | Preliminary |
This type is under development and is subject to change.
Detailed Description
FunctionSorter allows user to define the designated 'sort' method and it will be evaluated to sort the data. The method takes two arguments (lhs and rhs) of the specified parameter type and the data can be accessed as below for evaluation,
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) } } ] }
Note: The user needs to explicitly invoke SortFilterProxyModel::invalidateSorter whenever any external qml property used within the designated 'sort' method changes. This behaviour is subject to change in the future, like implicit invalidation and thus the user doesn't need to explicitly invoke 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.