Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QProxyModel Class Reference

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

    #include <QProxyModel>

Inherits QAbstractItemModel.

- List of all members, including inherited members

### Writable Properties

- 1 writable property inherited from QObject

### Public Functions

- QProxyModel ( QObject * parent = 0 )
- ~QProxyModel ()
- virtual int columnCount ( const QModelIndex & parent ) const
- virtual QVariant data ( const QModelIndex & index, int role ) const
- virtual bool dropMimeData ( const QMimeData * data, QDrag::DropAction action, int row, const QModelIndex & parent )
- virtual void fetchMore ( const QModelIndex & parent )
- virtual QAbstractItemModel::ItemFlags flags ( const QModelIndex & index ) const
- virtual bool hasChildren ( const QModelIndex & parent ) const
- virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const
- virtual QModelIndex index ( int row, int column, const QModelIndex & parent ) const
- virtual bool insertColumns ( int column, int count, const QModelIndex & parent )
- virtual bool insertRows ( int row, int count, const QModelIndex & parent )
- QModelIndexList match ( const QModelIndex & start, int role, const QVariant & value, int hits, QAbstractItemModel::MatchFlags flags ) const
- virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const
- virtual QStringList mimeTypes () const
- QAbstractItemModel * model () const
- virtual QModelIndex parent ( const QModelIndex & child ) const
- virtual int rowCount ( const QModelIndex & parent ) const
- virtual bool setData ( const QModelIndex & index, const QVariant & value, int role )
- virtual bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role )
- virtual void setModel ( QAbstractItemModel * model )
- virtual void sort ( int column, Qt::SortOrder order )
- virtual QSize span ( const QModelIndex & index ) const
- virtual QDrag::DropActions supportedDropActions () const

- 31 public functions inherited from QAbstractItemModel
- 26 public functions inherited from QObject

### Public Slots

- virtual void revert ()
- virtual bool submit ()

- 2 public slots inherited from QAbstractItemModel
- 1 public slot inherited from QObject

### Signals

- 6 signals inherited from QAbstractItemModel
- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QObject

### Protected Functions

- 1 protected function inherited from QAbstractItemModel
- 7 protected functions inherited from QObject

## Detailed Description

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

Proxy models provide a standard model interface

See also Model/View Programming and QAbstractItemModel.

## Member Function Documentation

### 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 ) const `[virtual]`

Returns the number of columns for the given parent.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::columnCount().

### QVariant QProxyModel::data ( const QModelIndex & index, int role ) const `[virtual]`

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

Reimplemented from QAbstractItemModel.

### bool QProxyModel::dropMimeData ( const QMimeData * data, QDrag::DropAction action, int row, const QModelIndex & parent ) `[virtual]`

### void QProxyModel::fetchMore ( const QModelIndex & parent ) `[virtual]`

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.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::fetchMore().

### QAbstractItemModel::ItemFlags QProxyModel::flags ( const QModelIndex & index ) const `[virtual]`

Returns the item flags for the given index.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::flags().

### bool QProxyModel::hasChildren ( const QModelIndex & parent ) const `[virtual]`

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

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::hasChildren().

### QVariant QProxyModel::headerData ( int section, Qt::Orientation orientation, int role ) const `[virtual]`

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

Reimplemented from QAbstractItemModel.

### QModelIndex QProxyModel::index ( int row, int column, const QModelIndex & parent ) const `[virtual]`

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

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::index().

### bool QProxyModel::insertColumns ( int column, int count, const QModelIndex & parent ) `[virtual]`

Inserts 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.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::insertColumns().

### bool QProxyModel::insertRows ( int row, int count, const QModelIndex & parent ) `[virtual]`

Inserts 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.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::insertRows().

### QModelIndexList QProxyModel::match ( const QModelIndex & start, int role, const QVariant & value, int hits, QAbstractItemModel::MatchFlags flags ) const

Returns a list of model indexes that each contain the given value for the 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` is specified in flags.

See also QAbstractItemModel::match().

### QMimeData * QProxyModel::mimeData ( const QModelIndexList & indexes ) const `[virtual]`

### QStringList QProxyModel::mimeTypes () const `[virtual]`

### QAbstractItemModel * QProxyModel::model () const

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

### QModelIndex QProxyModel::parent ( const QModelIndex & child ) const `[virtual]`

Returns the model index that corresponds to the parent of the given child index.

Reimplemented from QAbstractItemModel.

### void QProxyModel::revert () `[virtual slot]`

Reimplemented from QAbstractItemModel.

### int QProxyModel::rowCount ( const QModelIndex & parent ) const `[virtual]`

Returns the number of rows for the given parent.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::rowCount().

### bool QProxyModel::setData ( const QModelIndex & index, const QVariant & value, int role ) `[virtual]`

Sets the role data for the item at index to value. Returns true if successful; otherwise returns false.

The base class implementation returns false. This function and data() must be reimplemented for editable models.

Reimplemented from QAbstractItemModel.

See also data(), itemData(), and QAbstractItemModel::setData().

### bool QProxyModel::setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role ) `[virtual]`

Sets the role data in the section of the header with the specified orientation to the value given.

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::setHeaderData().

### void QProxyModel::setModel ( QAbstractItemModel * model ) `[virtual]`

Sets the given model to be processed by the proxy model.

### void QProxyModel::sort ( int column, Qt::SortOrder order ) `[virtual]`

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

Reimplemented from QAbstractItemModel.

See also QAbstractItemModel::sort().

### QSize QProxyModel::span ( const QModelIndex & index ) const `[virtual]`

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

Reimplemented from QAbstractItemModel.

### bool QProxyModel::submit () `[virtual slot]`

Reimplemented from QAbstractItemModel.

### QDrag::DropActions QProxyModel::supportedDropActions () const `[virtual]`