QProxyModel Class

The QProxyModel class provides support for processing data passed between another model and a view. 更多...

頭: #include <QProxyModel>
繼承: QAbstractItemModel

該類已過時。 提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。

公共函數

QProxyModel (QObject * parent = 0)
~QProxyModel ()
QAbstractItemModel * model () const
virtual void setModel (QAbstractItemModel * model )

重實現公共函數

virtual int columnCount (const QModelIndex & parent = QModelIndex()) const
virtual QVariant data (const QModelIndex & index , int role = Qt::DisplayRole) const
virtual bool dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent )
virtual void fetchMore (const QModelIndex & parent )
virtual Qt::ItemFlags flags (const QModelIndex & index ) const
virtual bool hasChildren (const QModelIndex & parent = QModelIndex()) const
virtual QVariant headerData (int section , Qt::Orientation orientation , int role = Qt::DisplayRole) const
virtual QModelIndex index (int row , int column , const QModelIndex & parent = QModelIndex()) const
virtual bool insertColumns (int column , int count , const QModelIndex & parent = QModelIndex())
virtual bool insertRows (int row , int count , const QModelIndex & parent = QModelIndex())
virtual QModelIndexList match (const QModelIndex & start , int role , const QVariant & value , int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) const
virtual QMimeData * mimeData (const QModelIndexList & indexes ) const
virtual QStringList mimeTypes () const
virtual QModelIndex parent (const QModelIndex & child ) const
virtual void revert ()
virtual int rowCount (const QModelIndex & parent = QModelIndex()) const
virtual bool setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole)
virtual bool setHeaderData (int section , Qt::Orientation orientation , const QVariant & value , int role = Qt::EditRole)
virtual void sort (int column , Qt::SortOrder order = Qt::AscendingOrder)
virtual QSize span (const QModelIndex & index ) const
virtual bool submit ()
virtual Qt::DropActions supportedDropActions () const

額外繼承成員

詳細描述

The QProxyModel class provides support for processing data passed between another model and a view.

If you want to do filtering and sorting, see QSortFilterProxyModel .

Proxy models provide a standard model interface that can be used to manipulate the data retrieved through an underlying model. They can be used to perform operations such as sorting and filtering on the data obtained without changing the contents of the model.

Just as with subclasses of QAbstractItemView , QProxyModel 提供 setModel () function that is used to specify the model to be acted on by the proxy. Views can be connected to either the underlying model or the proxy model with QAbstractItemView::setModel ().

Since views rely on the information provided in model indexes to identify items of data from models, and to position these items in some visual representation, proxy models must create their own model indexes instead of supplying model indexes from their underlying models.

另請參閱 模型/視圖編程 and QAbstractItemModel .

成員函數文檔編製

QProxyModel:: QProxyModel ( QObject * parent = 0)

Constructs a proxy model with the given parent .

QProxyModel:: ~QProxyModel ()

Destroys the proxy model.

[虛擬] int QProxyModel:: columnCount (const QModelIndex & parent = QModelIndex()) const

重實現自 QAbstractItemModel::columnCount ().

Returns the number of columns for the given parent .

另請參閱 QAbstractItemModel::columnCount ().

[虛擬] QVariant QProxyModel:: data (const QModelIndex & index , int role = Qt::DisplayRole) const

重實現自 QAbstractItemModel::data ().

Returns the data stored in the item with the given index under the specified role .

另請參閱 setData ().

[虛擬] bool QProxyModel:: dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent )

重實現自 QAbstractItemModel::dropMimeData ().

Returns true if the model accepts the data dropped onto an attached view for the specified action ;否則返迴 false。

The parent , row ,和 column details can be used to control which MIME types are acceptable to different parts of a model when received via the drag and drop system.

[虛擬] void QProxyModel:: fetchMore (const QModelIndex & parent )

重實現自 QAbstractItemModel::fetchMore ().

Fetches more child items of the given parent . This function is used by views to tell the model that they can display more data than the model has provided.

另請參閱 QAbstractItemModel::fetchMore ().

[虛擬] Qt::ItemFlags QProxyModel:: flags (const QModelIndex & index ) const

重實現自 QAbstractItemModel::flags ().

返迴項標誌為給定 index .

[虛擬] bool QProxyModel:: hasChildren (const QModelIndex & parent = QModelIndex()) const

重實現自 QAbstractItemModel::hasChildren ().

Returns true if the item corresponding to the parent index has child items; otherwise returns false.

另請參閱 QAbstractItemModel::hasChildren ().

[虛擬] QVariant QProxyModel:: headerData ( int section , Qt::Orientation orientation , int role = Qt::DisplayRole) const

重實現自 QAbstractItemModel::headerData ().

Returns the data stored in the section of the header with specified orientation under the given role .

另請參閱 setHeaderData ().

[虛擬] QModelIndex QProxyModel:: index ( int row , int column , const QModelIndex & parent = QModelIndex()) const

重實現自 QAbstractItemModel::index ().

Returns the model index with the given row , column ,和 parent .

另請參閱 QAbstractItemModel::index ().

[虛擬] bool QProxyModel:: insertColumns ( int column , int count , const QModelIndex & parent = QModelIndex())

重實現自 QAbstractItemModel::insertColumns ().

插入 count columns into the model, creating new items as children of the given parent . The new columns are inserted before the column specified. If the parent item has no children, a single row is created to contain the required number of columns.

Returns true if the columns were successfully inserted; otherwise returns false.

另請參閱 QAbstractItemModel::insertColumns ().

[虛擬] bool QProxyModel:: insertRows ( int row , int count , const QModelIndex & parent = QModelIndex())

重實現自 QAbstractItemModel::insertRows ().

插入 count rows into the model, creating new items as children of the given parent . The new rows are inserted before the row specified. If the parent item has no children, a single column is created to contain the required number of rows.

Returns true if the rows were successfully inserted; otherwise returns false.

另請參閱 QAbstractItemModel::insertRows ().

[虛擬] QModelIndexList QProxyModel:: match (const QModelIndex & start , int role , const QVariant & value , int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) const

重實現自 QAbstractItemModel::match ().

Returns a list of model indexes that each contain the given value role specified. The search begins at the start index and is performed according to the specified flags . The search continues until the number of matching data items equals hits , the last row is reached, or the search reaches start again, depending on whether MatchWrap 指定在 flags .

另請參閱 QAbstractItemModel::match ().

[虛擬] QMimeData * QProxyModel:: mimeData (const QModelIndexList & indexes ) const

重實現自 QAbstractItemModel::mimeData ().

Returns MIME data for the specified indexes in the model.

[虛擬] QStringList QProxyModel:: mimeTypes () const

重實現自 QAbstractItemModel::mimeTypes ().

Returns a list of MIME types that are supported by the model.

QAbstractItemModel * QProxyModel:: model () const

Returns the model that contains the data that is available through the proxy model.

另請參閱 setModel ().

[虛擬] QModelIndex QProxyModel:: parent (const QModelIndex & child ) const

重實現自 QAbstractItemModel::parent ().

Returns the model index that corresponds to the parent of the given child 索引。

[虛擬] void QProxyModel:: revert ()

重實現自 QAbstractItemModel::revert ().

[虛擬] int QProxyModel:: rowCount (const QModelIndex & parent = QModelIndex()) const

重實現自 QAbstractItemModel::rowCount ().

Returns the number of rows for the given parent .

另請參閱 QAbstractItemModel::rowCount ().

[虛擬] bool QProxyModel:: setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole)

重實現自 QAbstractItemModel::setData ().

設置 role 數據為項在 index to value . Returns true if successful; otherwise returns false.

The base class implementation returns false. This function and data () 必須被重實現為可編輯模型。

另請參閱 data (), itemData (),和 QAbstractItemModel::setData ().

[虛擬] bool QProxyModel:: setHeaderData ( int section , Qt::Orientation orientation , const QVariant & value , int role = Qt::EditRole)

重實現自 QAbstractItemModel::setHeaderData ().

設置 role data in the section of the header with the specified orientation value 給定。

另請參閱 headerData () 和 QAbstractItemModel::setHeaderData ().

[虛擬] void QProxyModel:: setModel ( QAbstractItemModel * model )

設置給定 model to be processed by the proxy model.

另請參閱 model ().

[虛擬] void QProxyModel:: sort ( int column , Qt::SortOrder order = Qt::AscendingOrder)

重實現自 QAbstractItemModel::sort ().

Sorts the child items in the specified column according to the sort order defined by order .

另請參閱 QAbstractItemModel::sort ().

[虛擬] QSize QProxyModel:: span (const QModelIndex & index ) const

重實現自 QAbstractItemModel::span ().

Returns the size of the item that corresponds to the specified index .

[虛擬] bool QProxyModel:: submit ()

重實現自 QAbstractItemModel::submit ().

[虛擬] Qt::DropActions QProxyModel:: supportedDropActions () const

重實現自 QAbstractItemModel::supportedDropActions ().

Returns the drop actions that are supported by the model; this is a combination of the individual actions defined in Qt::DropActions .

The selection of drop actions provided by the model will influence the behavior of the component that started the drag and drop operation.

另請參閱 拖放 .