The QSortFilterProxyModel class provides support for sorting and filtering data passed between another model and a view. 更多...
头: | #include <QSortFilterProxyModel> |
qmake: | QT += core |
Since: | Qt 4.1 |
继承: | QAbstractProxyModel |
|
|
QSortFilterProxyModel (QObject * parent = nullptr) | |
virtual | ~QSortFilterProxyModel () |
bool | dynamicSortFilter () const |
Qt::CaseSensitivity | filterCaseSensitivity () const |
int | filterKeyColumn () const |
QRegExp | filterRegExp () const |
QRegularExpression | filterRegularExpression () const |
int | filterRole () const |
bool | isRecursiveFilteringEnabled () const |
bool | isSortLocaleAware () const |
void | setDynamicSortFilter (bool enable ) |
void | setFilterCaseSensitivity (Qt::CaseSensitivity cs ) |
void | setFilterKeyColumn (int column ) |
void | setFilterRole (int role ) |
void | setRecursiveFilteringEnabled (bool recursive ) |
void | setSortCaseSensitivity (Qt::CaseSensitivity cs ) |
void | setSortLocaleAware (bool on ) |
void | setSortRole (int role ) |
Qt::CaseSensitivity | sortCaseSensitivity () const |
int | sortColumn () const |
Qt::SortOrder | sortOrder () const |
int | sortRole () const |
virtual QModelIndex | buddy (const QModelIndex & index ) const override |
virtual bool | canFetchMore (const QModelIndex & parent ) const override |
virtual int | columnCount (const QModelIndex & parent = QModelIndex()) const override |
virtual QVariant | data (const QModelIndex & index , int role = Qt::DisplayRole) const override |
virtual bool | dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) override |
virtual void | fetchMore (const QModelIndex & parent ) override |
virtual Qt::ItemFlags | flags (const QModelIndex & index ) const override |
virtual bool | hasChildren (const QModelIndex & parent = QModelIndex()) const override |
virtual QVariant | headerData (int section , Qt::Orientation orientation , int role = Qt::DisplayRole) const override |
virtual QModelIndex | index (int row , int column , const QModelIndex & parent = QModelIndex()) const override |
virtual bool | insertColumns (int column , int count , const QModelIndex & parent = QModelIndex()) override |
virtual bool | insertRows (int row , int count , const QModelIndex & parent = QModelIndex()) override |
virtual QModelIndex | mapFromSource (const QModelIndex & sourceIndex ) const override |
virtual QItemSelection | mapSelectionFromSource (const QItemSelection & sourceSelection ) const override |
virtual QItemSelection | mapSelectionToSource (const QItemSelection & proxySelection ) const override |
virtual QModelIndex | mapToSource (const QModelIndex & proxyIndex ) const override |
virtual QModelIndexList | match (const QModelIndex & start , int role , const QVariant & value , int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override |
virtual QMimeData * | mimeData (const QModelIndexList & indexes ) const override |
virtual QStringList | mimeTypes () const override |
virtual QModelIndex | parent (const QModelIndex & child ) const override |
virtual bool | removeColumns (int column , int count , const QModelIndex & parent = QModelIndex()) override |
virtual bool | removeRows (int row , int count , const QModelIndex & parent = QModelIndex()) override |
virtual int | rowCount (const QModelIndex & parent = QModelIndex()) const override |
virtual bool | setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole) override |
virtual bool | setHeaderData (int section , Qt::Orientation orientation , const QVariant & value , int role = Qt::EditRole) override |
virtual void | setSourceModel (QAbstractItemModel * sourceModel ) override |
virtual QModelIndex | sibling (int row , int column , const QModelIndex & idx ) const override |
virtual void | sort (int column , Qt::SortOrder order = Qt::AscendingOrder) override |
virtual QSize | span (const QModelIndex & index ) const override |
virtual Qt::DropActions | supportedDropActions () const override |
void | invalidate () |
void | setFilterFixedString (const QString & pattern ) |
void | setFilterRegExp (const QRegExp & regExp ) |
void | setFilterRegExp (const QString & pattern ) |
void | setFilterRegularExpression (const QString & pattern ) |
void | setFilterRegularExpression (const QRegularExpression & regularExpression ) |
void | setFilterWildcard (const QString & pattern ) |
const QMetaObject | staticMetaObject |
virtual bool | filterAcceptsColumn (int source_column , const QModelIndex & source_parent ) const |
virtual bool | filterAcceptsRow (int source_row , const QModelIndex & source_parent ) const |
void | invalidateFilter () |
virtual bool | lessThan (const QModelIndex & source_left , const QModelIndex & source_right ) const |
The QSortFilterProxyModel class provides support for sorting and filtering data passed between another model and a view.
QSortFilterProxyModel can be used for sorting items, filtering out items, or both. The model transforms 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, and without duplicating the data in memory.
Let's assume that we want to sort and filter the items provided by a custom model. The code to set up the model and the view, without sorting and filtering, would look like this:
QTreeView *treeView = new QTreeView; MyItemModel *model = new MyItemModel(this); treeView->setModel(model);
To add sorting and filtering support to
MyItemModel
, we need to create a
QSortFilterProxyModel
,调用
setSourceModel
() 采用
MyItemModel
as argument, and install the
QSortFilterProxyModel
on the view:
QTreeView *treeView = new QTreeView; MyItemModel *sourceModel = new MyItemModel(this); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(sourceModel); treeView->setModel(proxyModel);
At this point, neither sorting nor filtering is enabled; the original data is displayed in the view. Any changes made through the QSortFilterProxyModel are applied to the original model.
The QSortFilterProxyModel acts as a wrapper for the original model. If you need to convert source QModelIndex es to sorted/filtered model indexes or vice versa, use mapToSource (), mapFromSource (), mapSelectionToSource (),和 mapSelectionFromSource ().
注意: By default, the model dynamically re-sorts and re-filters data whenever the original model changes. This behavior can be changed by setting the dynamicSortFilter 特性。
The Basic Sort/Filter Model and Custom Sort/Filter Model 范例阐明如何使用 QSortFilterProxyModel to perform basic sorting and filtering and how to subclass it to implement custom behavior.
QTableView and QTreeView 拥有 sortingEnabled property that controls whether the user can sort the view by clicking the view's horizontal header. For example:
treeView->setSortingEnabled(true);
When this feature is on (the default is off), clicking on a header section sorts the items according to that column. By clicking repeatedly, the user can alternate between ascending and descending order.
Behind the scene, the view calls the
sort
() virtual function on the model to reorder the data in the model. To make your data sortable, you can either implement
sort
() in your model, or use a
QSortFilterProxyModel
to wrap your model --
QSortFilterProxyModel
provides a generic
sort
() reimplementation that operates on the
sortRole
() (
Qt::DisplayRole
by default) of the items and that understands several data types, including
int
,
QString
,和
QDateTime
. For hierarchical models, sorting is applied recursively to all child items. String comparisons are case sensitive by default; this can be changed by setting the
sortCaseSensitivity
特性。
Custom sorting behavior is achieved by subclassing QSortFilterProxyModel 并重实现 lessThan (), which is used to compare items. For example:
bool MySortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { QVariant leftData = sourceModel()->data(left); QVariant rightData = sourceModel()->data(right); if (leftData.type() == QVariant::DateTime) { return leftData.toDateTime() < rightData.toDateTime(); } else { static const QRegularExpression emailPattern("[\\w\\.]*@[\\w\\.]*"); QString leftString = leftData.toString(); if (left.column() == 1) { const QRegularExpressionMatch match = emailPattern.match(leftString); if (match.hasMatch()) leftString = match.captured(0); } QString rightString = rightData.toString(); if (right.column() == 1) { const QRegularExpressionMatch match = emailPattern.match(rightString); if (match.hasMatch()) rightString = match.captured(0); } return QString::localeAwareCompare(leftString, rightString) < 0; } }
(This code snippet comes from the Custom Sort/Filter Model example.)
An alternative approach to sorting is to disable sorting on the view and to impose a certain order to the user. This is done by explicitly calling sort () with the desired column and order as arguments on the QSortFilterProxyModel (or on the original model if it implements sort ()). For example:
proxyModel->sort(2, Qt::AscendingOrder);
QSortFilterProxyModel can be sorted by column -1, in which case it returns to the sort order of the underlying source model.
In addition to sorting, QSortFilterProxyModel can be used to hide items that do not match a certain filter. The filter is specified using a QRegExp object and is applied to the filterRole () ( Qt::DisplayRole by default) of each item, for a given column. The QRegExp object can be used to match a regular expression, a wildcard pattern, or a fixed string. For example:
proxyModel->setFilterRegExp(QRegExp(".png", Qt::CaseInsensitive, QRegExp::FixedString)); proxyModel->setFilterKeyColumn(1);
For hierarchical models, the filter is applied recursively to all children. If a parent item doesn't match the filter, none of its children will be shown.
A common use case is to let the user specify the filter regular expression, wildcard pattern, or fixed string in a QLineEdit and to connect the textChanged() signal to setFilterRegularExpression (), setFilterWildcard (),或 setFilterFixedString () to reapply the filter.
Custom filtering behavior can be achieved by reimplementing the filterAcceptsRow () 和 filterAcceptsColumn () functions. For example (from the Custom Sort/Filter Model example), the following implementation ignores the filterKeyColumn property and performs filtering on columns 0, 1, and 2:
bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); return (sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index1).toString().contains(filterRegExp())) && dateInRange(sourceModel()->data(index2).toDate()); }
(This code snippet comes from the Custom Sort/Filter Model example.)
If you are working with large amounts of filtering and have to invoke invalidateFilter () repeatedly, using reset() may be more efficient, depending on the implementation of your model. However, reset() returns the proxy model to its original state, losing selection information, and will cause the proxy model to be repopulated.
由于 QAbstractProxyModel and its subclasses are derived from QAbstractItemModel , much of the same advice about subclassing normal models also applies to proxy models. In addition, it is worth noting that many of the default implementations of functions in this class are written so that they call the equivalent functions in the relevant source model. This simple proxying mechanism may need to be overridden for source models with more complex behavior; for example, if the source model provides a custom hasChildren () implementation, you should also provide one in the proxy model.
注意: Some general guidelines for subclassing models are available in the 模型子类化参考 .
注意: With Qt 5, regular expression support has been improved through the QRegularExpression 类。 QSortFilterProxyModel dating back prior to that class creation, it originally supported only QRegExp . Since Qt 5.12, QRegularExpression APIs have been added. Therefore, QRegExp APIs should be considered deprecated and the QRegularExpression version should be used in place.
警告: Don't mix calls to the getters and setters of different regexp types as this will lead to unexpected results. For maximum compatibility, the original implementation has been kept. Therefore, if, for example, a call to setFilterRegularExpression is made followed by another one to setFilterFixedString , the first call will setup a QRegularExpression object to use as filter while the second will setup a QRegExp in FixedString mode. However, this is an implementation detail that might change in the future.
另请参阅 QAbstractProxyModel , QAbstractItemModel , 模型/视图编程 , 基本排序/过滤模型范例 , 自定义排序/过滤模型范例 ,和 QIdentityProxyModel .
This property holds whether the proxy model is dynamically sorted and filtered whenever the contents of the source model change
Note that you should not update the source model through the proxy model when dynamicSortFilter is true. For instance, if you set the proxy model on a QComboBox , then using functions that update the model, e.g., addItem() , will not work as expected. An alternative is to set dynamicSortFilter to false and call sort() after adding items to the QComboBox .
默认值为 true。
该特性在 Qt 4.2 引入。
访问函数:
bool | dynamicSortFilter () const |
void | setDynamicSortFilter (bool enable ) |
This property holds the case sensitivity of the QRegExp pattern used to filter the contents of the source model
By default, the filter is case sensitive.
访问函数:
Qt::CaseSensitivity | filterCaseSensitivity () const |
void | setFilterCaseSensitivity (Qt::CaseSensitivity cs ) |
另请参阅 filterRegExp and sortCaseSensitivity .
This property holds the column where the key used to filter the contents of the source model is read from.
The default value is 0. If the value is -1, the keys will be read from all columns.
访问函数:
int | filterKeyColumn () const |
void | setFilterKeyColumn (int column ) |
此特性保持 QRegExp used to filter the contents of the source model
Setting this property overwrites the current filterCaseSensitivity . By default, the QRegExp is an empty string matching all contents.
若无 QRegExp or an empty string is set, everything in the source model will be accepted.
访问函数:
QRegExp | filterRegExp () const |
void | setFilterRegExp (const QString & pattern ) |
void | setFilterRegExp (const QRegExp & regExp ) |
另请参阅 filterCaseSensitivity , setFilterWildcard (),和 setFilterFixedString ().
此特性保持 QRegularExpression used to filter the contents of the source model
Setting this property overwrites the current filterCaseSensitivity . By default, the QRegularExpression is an empty string matching all contents.
若无 QRegularExpression or an empty string is set, everything in the source model will be accepted.
该特性在 Qt 5.12 引入。
访问函数:
QRegularExpression | filterRegularExpression () const |
void | setFilterRegularExpression (const QString & pattern ) |
void | setFilterRegularExpression (const QRegularExpression & regularExpression ) |
另请参阅 filterCaseSensitivity , setFilterWildcard (),和 setFilterFixedString ().
This property holds the item role that is used to query the source model's data when filtering items
默认值为 Qt::DisplayRole .
该特性在 Qt 4.2 引入。
访问函数:
int | filterRole () const |
void | setFilterRole (int role ) |
另请参阅 filterAcceptsRow ().
This property holds the local aware setting used for comparing strings when sorting
By default, sorting is not local aware.
该特性在 Qt 4.3 引入。
访问函数:
bool | isSortLocaleAware () const |
void | setSortLocaleAware (bool on ) |
另请参阅 sortCaseSensitivity and lessThan ().
This property holds whether the filter to be applied recursively on children, and for any matching child, its parents will be visible as well.
默认值为 false。
该特性在 Qt 5.10 引入。
访问函数:
bool | isRecursiveFilteringEnabled () const |
void | setRecursiveFilteringEnabled (bool recursive ) |
另请参阅 filterAcceptsRow ().
This property holds the case sensitivity setting used for comparing strings when sorting
By default, sorting is case sensitive.
该特性在 Qt 4.2 引入。
访问函数:
Qt::CaseSensitivity | sortCaseSensitivity () const |
void | setSortCaseSensitivity (Qt::CaseSensitivity cs ) |
另请参阅 filterCaseSensitivity and lessThan ().
This property holds the item role that is used to query the source model's data when sorting items
默认值为 Qt::DisplayRole .
该特性在 Qt 4.2 引入。
访问函数:
int | sortRole () const |
void | setSortRole (int role ) |
另请参阅 lessThan ().
Constructs a sorting filter model with the given parent .
[虚拟]
QSortFilterProxyModel::
~QSortFilterProxyModel
()
Destroys this sorting filter model.
[override virtual]
QModelIndex
QSortFilterProxyModel::
buddy
(const
QModelIndex
&
index
) const
重实现自 QAbstractProxyModel::buddy ().
[override virtual]
bool
QSortFilterProxyModel::
canFetchMore
(const
QModelIndex
&
parent
) const
重实现自 QAbstractProxyModel::canFetchMore ().
[override virtual]
int
QSortFilterProxyModel::
columnCount
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现自 QAbstractItemModel::columnCount ().
[override virtual]
QVariant
QSortFilterProxyModel::
data
(const
QModelIndex
&
index
,
int
role
= Qt::DisplayRole) const
重实现自 QAbstractProxyModel::data ().
另请参阅 setData ().
[override virtual]
bool
QSortFilterProxyModel::
dropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
)
重实现自 QAbstractProxyModel::dropMimeData ().
[override virtual]
void
QSortFilterProxyModel::
fetchMore
(const
QModelIndex
&
parent
)
重实现自 QAbstractProxyModel::fetchMore ().
[virtual protected]
bool
QSortFilterProxyModel::
filterAcceptsColumn
(
int
source_column
, const
QModelIndex
&
source_parent
) const
返回
true
if the item in the column indicated by the given
source_column
and
source_parent
should be included in the model; otherwise returns
false
.
默认实现返回
true
if the value held by the relevant item matches the filter string, wildcard string or regular expression.
注意: 默认情况下, Qt::DisplayRole is used to determine if the column should be accepted or not. This can be changed by setting the filterRole 特性。
另请参阅 filterAcceptsRow (), setFilterFixedString (), setFilterRegExp (),和 setFilterWildcard ().
[virtual protected]
bool
QSortFilterProxyModel::
filterAcceptsRow
(
int
source_row
, const
QModelIndex
&
source_parent
) const
返回
true
if the item in the row indicated by the given
source_row
and
source_parent
should be included in the model; otherwise returns false.
默认实现返回
true
if the value held by the relevant item matches the filter string, wildcard string or regular expression.
注意: 默认情况下, Qt::DisplayRole is used to determine if the row should be accepted or not. This can be changed by setting the filterRole 特性。
另请参阅 filterAcceptsColumn (), setFilterFixedString (), setFilterRegExp (),和 setFilterWildcard ().
[override virtual]
Qt::ItemFlags
QSortFilterProxyModel::
flags
(const
QModelIndex
&
index
) const
重实现自 QAbstractProxyModel::flags ().
[override virtual]
bool
QSortFilterProxyModel::
hasChildren
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现自 QAbstractProxyModel::hasChildren ().
[override virtual]
QVariant
QSortFilterProxyModel::
headerData
(
int
section
,
Qt::Orientation
orientation
,
int
role
= Qt::DisplayRole) const
重实现自 QAbstractProxyModel::headerData ().
另请参阅 setHeaderData ().
[override virtual]
QModelIndex
QSortFilterProxyModel::
index
(
int
row
,
int
column
, const
QModelIndex
&
parent
= QModelIndex()) const
重实现自 QAbstractItemModel::index ().
[override virtual]
bool
QSortFilterProxyModel::
insertColumns
(
int
column
,
int
count
, const
QModelIndex
&
parent
= QModelIndex())
重实现自 QAbstractItemModel::insertColumns ().
[override virtual]
bool
QSortFilterProxyModel::
insertRows
(
int
row
,
int
count
, const
QModelIndex
&
parent
= QModelIndex())
重实现自 QAbstractItemModel::insertRows ().
[slot]
void
QSortFilterProxyModel::
invalidate
()
Invalidates the current sorting and filtering.
该函数在 Qt 4.3 引入。
另请参阅 invalidateFilter ().
[protected]
void
QSortFilterProxyModel::
invalidateFilter
()
Invalidates the current filtering.
This function should be called if you are implementing custom filtering (e.g. filterAcceptsRow ()), and your filter parameters have changed.
该函数在 Qt 4.3 引入。
另请参阅 invalidate ().
[virtual protected]
bool
QSortFilterProxyModel::
lessThan
(const
QModelIndex
&
source_left
, const
QModelIndex
&
source_right
) const
返回
true
if the value of the item referred to by the given index
source_left
is less than the value of the item referred to by the given index
source_right
,否则返回
false
.
This function is used as the < operator when sorting, and handles the following QVariant types:
Any other type will be converted to a QString 使用 QVariant::toString ().
Comparison of QString s is case sensitive by default; this can be changed using the sortCaseSensitivity 特性。
默认情况下, Qt::DisplayRole associated with the QModelIndex es is used for comparisons. This can be changed by setting the sortRole 特性。
注意: The indices passed in correspond to the source model.
另请参阅 sortRole , sortCaseSensitivity ,和 dynamicSortFilter .
[override virtual]
QModelIndex
QSortFilterProxyModel::
mapFromSource
(const
QModelIndex
&
sourceIndex
) const
重实现自 QAbstractProxyModel::mapFromSource ().
Returns the model index in the QSortFilterProxyModel given the sourceIndex from the source model.
另请参阅 mapToSource ().
[override virtual]
QItemSelection
QSortFilterProxyModel::
mapSelectionFromSource
(const
QItemSelection
&
sourceSelection
) const
重实现自 QAbstractProxyModel::mapSelectionFromSource ().
[override virtual]
QItemSelection
QSortFilterProxyModel::
mapSelectionToSource
(const
QItemSelection
&
proxySelection
) const
重实现自 QAbstractProxyModel::mapSelectionToSource ().
[override virtual]
QModelIndex
QSortFilterProxyModel::
mapToSource
(const
QModelIndex
&
proxyIndex
) const
重实现自 QAbstractProxyModel::mapToSource ().
Returns the source model index corresponding to the given proxyIndex from the sorting filter model.
另请参阅 mapFromSource ().
[override virtual]
QModelIndexList
QSortFilterProxyModel::
match
(const
QModelIndex
&
start
,
int
role
, const
QVariant
&
value
,
int
hits
= 1,
Qt::MatchFlags
flags
= Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
重实现自 QAbstractItemModel::match ().
[override virtual]
QMimeData
*QSortFilterProxyModel::
mimeData
(const
QModelIndexList
&
indexes
) const
重实现自 QAbstractProxyModel::mimeData ().
[override virtual]
QStringList
QSortFilterProxyModel::
mimeTypes
() const
重实现自 QAbstractProxyModel::mimeTypes ().
[override virtual]
QModelIndex
QSortFilterProxyModel::
parent
(const
QModelIndex
&
child
) const
重实现自 QAbstractItemModel::parent ().
[override virtual]
bool
QSortFilterProxyModel::
removeColumns
(
int
column
,
int
count
, const
QModelIndex
&
parent
= QModelIndex())
重实现自 QAbstractItemModel::removeColumns ().
[override virtual]
bool
QSortFilterProxyModel::
removeRows
(
int
row
,
int
count
, const
QModelIndex
&
parent
= QModelIndex())
重实现自 QAbstractItemModel::removeRows ().
[override virtual]
int
QSortFilterProxyModel::
rowCount
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现自 QAbstractItemModel::rowCount ().
[override virtual]
bool
QSortFilterProxyModel::
setData
(const
QModelIndex
&
index
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现自 QAbstractProxyModel::setData ().
另请参阅 data ().
[slot]
void
QSortFilterProxyModel::
setFilterFixedString
(const
QString
&
pattern
)
Sets the fixed string used to filter the contents of the source model to the given pattern .
另请参阅 setFilterCaseSensitivity (), setFilterRegExp (), setFilterWildcard (),和 filterRegExp ().
[slot]
void
QSortFilterProxyModel::
setFilterRegExp
(const
QString
&
pattern
)
这是重载函数。
Sets the regular expression used to filter the contents of the source model to pattern .
注意: setter 函数对于特性 filterRegExp .
另请参阅 setFilterCaseSensitivity (), setFilterWildcard (), setFilterFixedString (),和 filterRegExp ().
[slot]
void
QSortFilterProxyModel::
setFilterRegularExpression
(const
QString
&
pattern
)
Sets the regular expression used to filter the contents of the source model to pattern .
This method should be preferred for new code as it will use QRegularExpression internally.
该函数在 Qt 5.12 引入。
注意: setter 函数对于特性 filterRegularExpression .
另请参阅 setFilterCaseSensitivity (), setFilterWildcard (), setFilterFixedString (),和 filterRegularExpression ().
[slot]
void
QSortFilterProxyModel::
setFilterWildcard
(const
QString
&
pattern
)
Sets the wildcard expression used to filter the contents of the source model to the given pattern .
另请参阅 setFilterCaseSensitivity (), setFilterRegExp (), setFilterFixedString (),和 filterRegExp ().
[override virtual]
bool
QSortFilterProxyModel::
setHeaderData
(
int
section
,
Qt::Orientation
orientation
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现自 QAbstractProxyModel::setHeaderData ().
另请参阅 headerData ().
[override virtual]
void
QSortFilterProxyModel::
setSourceModel
(
QAbstractItemModel
*
sourceModel
)
重实现自 QAbstractProxyModel::setSourceModel ().
[override virtual]
QModelIndex
QSortFilterProxyModel::
sibling
(
int
row
,
int
column
, const
QModelIndex
&
idx
) const
重实现自 QAbstractProxyModel::sibling ().
[override virtual]
void
QSortFilterProxyModel::
sort
(
int
column
,
Qt::SortOrder
order
= Qt::AscendingOrder)
重实现自 QAbstractProxyModel::sort ().
the column currently used for sorting
This returns the most recently used sort column.
该函数在 Qt 4.5 引入。
the order currently used for sorting
This returns the most recently used sort order.
该函数在 Qt 4.5 引入。
[override virtual]
QSize
QSortFilterProxyModel::
span
(const
QModelIndex
&
index
) const
重实现自 QAbstractProxyModel::span ().
[override virtual]
Qt::DropActions
QSortFilterProxyModel::
supportedDropActions
() const