Find
C
ase-sensitive
R
egexp search
Path
Showing
4087068c
from
2026-10-29
:
Absorb qtwebview submodule
qt
/
qtdeclarative
/
src
/
qmlmodels
/
sfpm
Navigation
Enable keyboard shortcuts
Name
Description
Size
Coverage
filters
-
qqmlsortfilterproxymodel.cpp
! \qmltype SortFilterProxyModel //! \nativetype QQmlSortFilterProxyModel \inqmlmodule QtQml.Models \since 6.10 \preliminary \brief Provides sorting and filtering capabilities for a \l QAbstractItemModel. SortFilterProxyModel inherits from \l QAbstractProxyModel, which handles the transformation of source indexes into proxy indexes. Sorting and filtering are controlled via the \l{SortFilterProxyModel::sorters}{sorters} and \l{SortFilterProxyModel::filters}{filters} properties, which determine the order of execution as specified in QML. This order can be overridden using the priority property available for each sorter. By default, all sorters share the same priority. SortFilterProxyModel enables users to sort and filter a \l QAbstractItemModel. The item views such as \l TableView or \l TreeView can utilize this proxy model to display filtered content. \note Currently, SortFilterProxyModel supports only QAbstractItemModel as the source model. The snippet below shows the configuration of sorters and filters in the QML SortFilterProxyModel: \qml ProcessModel { id: processModel } SortFilterProxyModel { id: sfpm sourceModel: processModel sorters: [ RoleSorter { roleName: "user" priority: 0 }, RoleSorter { roleName: "pid" priority: 1 } ] filters: [ FunctionFilter { function filter(cpuUsage: real) : bool { return (cpuUsage > 90) } } ] } \endqml The SortFilterProxyModel dynamically sorts and filters data whenever there is a change to the data in the source model and can be disabled through the \l{SortFilterProxyModel::}{dynamicSortFilter} property. The sorters \l RoleSorter, \l StringSorter and \l FunctionSorter can be configured in SortFilterProxyModel. Each sorter can be configured with a specific column index through \l{Sorter::}{column} property. If a column index is not specified, the sorting will be applied to the column index 0 of the model by default. The execution order of the sorter can be modified through the \l{Sorter::priority}{priority} property. This is particularly useful when performing hierarchical sorting, such as sorting data in the first column and then applying sorting to subsequent columns. To disable a specific sorter, \l{Sorter::}{enabled} can be set to \c false. The sorter priority can also be overridden by setting the primary sorter through the method call \l{SortFilterProxyModel::}{setPrimarySorter()}. This would be helpful in the case where the view wants to sort the data of any specific column by clicking on the column header such as in \l TableView, when there are other sorters also configured for the model. The filter \l ValueFilter and \l FunctionFilter can be configured in SortFilterProxyModel. Each filter can be set with the \l{FilterBase::}{column} property, similar to the sorter, to filter data in a specific column. If no column is specified, then the filter will be applied to all the column indexes in the model. To reduce the overhead of unwanted checks during filtering, it's recommended to specify the column index. To disable a specific filter, \l{FilterBase::}{enabled} can be set to \c false. \snippet qml/sortfilterproxymodel/qml-sortfilterproxymodel.qml sfpm-usage The AgeFilter in the above code snippet can be declared as follows \snippet qml/sortfilterproxymodel/AgeFilter.qml age-filter \note This API is considered tech preview and may change or be removed in future versions of Qt.
62803
-
qqmlsortfilterproxymodel_p.h
6147
-
qqmlsortfilterproxymodel_p_p.h
6605
-
qsortfilterproxymodelhelper.cpp
! \internal updates the mapping of the children when inserting or removing items
31543
-
qsortfilterproxymodelhelper_p.h
9693
-
sorters
-