Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QSortFilterProxyModel Class Reference
[QtGui module]

The QSortFilterProxyModel class provides support for sorting and filtering data passed between another model and a view. More...

#include <QSortFilterProxyModel>

Inherits QAbstractProxyModel.

This class was introduced in Qt 4.1.

Properties

Public Functions

Public Slots

Protected Functions

Additional Inherited Members


Detailed Description

The QSortFilterProxyModel class provides support for sorting and filtering data passed between another model and a view.

The sorting filter model transform the structure of a source model by mapping the model indexes it supplies to new indexes, corresponding to different locations, for views to use. This approach allows a given source model to be restructured as far as views are concerned without requiring any transformations on the underlying data.

The default implementation of the filter and sorting functions use the data for the items Qt::DisplayRole compare or accept items.

The default implementation of the lessThan() function used when sorting, can handle the following data types:

See also QAbstractProxyModel, QAbstractItemModel, and Model/View Programming.


Property Documentation

filterCaseSensitivity : Qt::CaseSensitivity

Access functions:

filterKeyColumn : int

This property holds the column where the key used to filter the contents of the source model is read from.

Access functions:

filterRegExp : QRegExp

This property holds the QRegExp used to filter the contents of the source model.

Setting this property overwrites the current caseSensitivity.

Access functions:

See also setCaseSensitivity(), setFilterWildcard(), and setFilterFixedString().


Member Function Documentation

QSortFilterProxyModel::QSortFilterProxyModel ( QObject * parent = 0 )

Constructs a sorting filter model with the given parent.

QSortFilterProxyModel::~QSortFilterProxyModel ()

Destroys the sorting filter model.

void QSortFilterProxyModel::clear ()   [slot]

Clears the sorting filter model, removing all mapping.

bool QSortFilterProxyModel::filterAcceptsColumn ( int source_column, const QModelIndex & source_parent ) const   [virtual protected]

Returns true if the value in the item in the column indicated by the given source_column and source_parent should be included in the model. The default implementation returns true.

bool QSortFilterProxyModel::filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const   [virtual protected]

Returns true if the value in the item in the row indicated by the given source_row and source_parent should be included in the model. The default implementation uses filterRegExp with the data returned for the Qt::DisplayRole to determine if the row should be accepted or not.

bool QSortFilterProxyModel::lessThan ( const QModelIndex & left, const QModelIndex & right ) const   [virtual protected]

Returns true if the value of the item referred to by the given index left is less than the value of the item referred to by the given index right, otherwise returns false. This function is used as the < operator when sorting, and handles several QVariant types:

QModelIndex QSortFilterProxyModel::mapFromSource ( const QModelIndex & sourceIndex ) const   [virtual]

Returns the model index in the QSortFilterProxyModel given the sourceIndex from the source model.

Reimplemented from QAbstractProxyModel.

QModelIndex QSortFilterProxyModel::mapToSource ( const QModelIndex & proxyIndex ) const   [virtual]

Returns the source model index corresponding to the given proxyIndex from the sorting filter model.

Reimplemented from QAbstractProxyModel.

void QSortFilterProxyModel::setFilterFixedString ( const QString & pattern )   [slot]

Sets the fixed string used to filter the contents of the source model to pattern.

See also setFilterCaseSensitivity(), setFilterRegExp(), and setFilterWildcard().

void QSortFilterProxyModel::setFilterWildcard ( const QString & pattern )   [slot]

Sets the wildcard expression used to filter the contents of the source model to pattern.

See also setFilterCaseSensitivity(), setFilterRegExp(), and setFilterFixedString().


Copyright © 2006 Trolltech Trademarks
Qt 4.1.1