SortFilterProxyModel

class qte.SortFilterProxyModel(model=None)

Applies per column filtering to PySide.QtGui.QSortFilterProxyModel.

This behaves almost exactly the same as PySide.QtGui.QSortFilterProxyModel, but allows separate filters for each column. Also, the filters are callables which take a value and return True (show) or False (hide).

This class inherits from HideProxyMixin, and provides all the expected mapping functions.

Members

New Methods

SortFilterProxyModel.filterFunction(column)

Return the filter function and role as set by setFilterFunction.

The return value is a tuple of (function, role). If no filter has been set, both values are None.

SortFilterProxyModel.setFilterFunction(column, func, role=<class 'DisplayRole'>)

Assign a filter function to a column.

role sets which role is used for obtaining the values passed to func. For example, to hide all rows with a red background in the second column:

def filter_function(value):
    if isinstance(value, QBrush):
        return value.color() != qte.QColor(QColor.red)
    else:
        return True
proxy.setFilterFunction(1, filter_function, qte.Qt.BackgroundRole)

Re-implemented Methods

SortFilterProxyModel.data(index, role)
SortFilterProxyModel.filterAcceptsRow(source_row, source_parent)
SortFilterProxyModel.headerData(section, orientation, role)
SortFilterProxyModel.mapColumnFromSource(column)
SortFilterProxyModel.mapColumnToSource(column)
SortFilterProxyModel.mapRowFromSource(row)
SortFilterProxyModel.mapRowToSource(row)
SortFilterProxyModel.setData(index, value, role)

Project Versions

Table Of Contents

Previous topic

SelectList

Next topic

TextEdit

This Page