Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QProxyModel Class

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

 #include <QProxyModel>

This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Inherits: QAbstractItemModel.

Public Functions

QAbstractItemModel(QObject * parent = 0)
QProxyModel(QObject * parent = 0)
virtual ~QAbstractItemModel()
~QProxyModel()
virtual QModelIndex buddy(const QModelIndex & index) const
virtual bool canDropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) const
virtual bool canFetchMore(const QModelIndex & parent) const
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const = 0
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const = 0
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
bool hasIndex(int row, int column, 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 = 0
bool insertColumn(int column, const QModelIndex & parent = QModelIndex())
virtual bool insertColumns(int column, int count, const QModelIndex & parent = QModelIndex())
bool insertRow(int row, const QModelIndex & parent = QModelIndex())
virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex())
virtual QMap<int, QVariant> itemData(const QModelIndex & index) const
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
QAbstractItemModel * model() const
bool moveColumn(const QModelIndex & sourceParent, int sourceColumn, const QModelIndex & destinationParent, int destinationChild)
virtual bool moveColumns(const QModelIndex & sourceParent, int sourceColumn, int count, const QModelIndex & destinationParent, int destinationChild)
bool moveRow(const QModelIndex & sourceParent, int sourceRow, const QModelIndex & destinationParent, int destinationChild)
virtual bool moveRows(const QModelIndex & sourceParent, int sourceRow, int count, const QModelIndex & destinationParent, int destinationChild)
virtual QModelIndex parent(const QModelIndex & index) const = 0
bool removeColumn(int column, const QModelIndex & parent = QModelIndex())
virtual bool removeColumns(int column, int count, const QModelIndex & parent = QModelIndex())
bool removeRow(int row, const QModelIndex & parent = QModelIndex())
virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex())
virtual QHash<int, QByteArray> roleNames() const
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const = 0
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 bool setItemData(const QModelIndex & index, const QMap<int, QVariant> & roles)
virtual void setModel(QAbstractItemModel * model)
QModelIndex sibling(int row, int column, const QModelIndex & index) const
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder)
virtual QSize span(const QModelIndex & index) const
virtual Qt::DropActions supportedDragActions() const
virtual Qt::DropActions supportedDropActions() const

Reimplemented Public Functions

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
  • 31 public functions inherited from QObject

Public Slots

virtual void revert()
virtual bool submit()
  • 1 public slot inherited from QObject

Signals

void columnsAboutToBeInserted(const QModelIndex & parent, int start, int end)
void columnsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
void columnsAboutToBeRemoved(const QModelIndex & parent, int start, int end)
void columnsInserted(const QModelIndex & parent, int start, int end)
void columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
void columnsRemoved(const QModelIndex & parent, int start, int end)
void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight, const QSet<int> & roles = QSet<int> ())
void headerDataChanged(Qt::Orientation orientation, int first, int last)
void layoutAboutToBeChanged(const QList<QPersistentModelIndex> & parents = QList<QPersistentModelIndex> ())
void layoutChanged(const QList<QPersistentModelIndex> & parents = QList<QPersistentModelIndex> ())
void modelAboutToBeReset()
void modelReset()
void rowsAboutToBeInserted(const QModelIndex & parent, int start, int end)
void rowsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end)
void rowsInserted(const QModelIndex & parent, int start, int end)
void rowsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
void rowsRemoved(const QModelIndex & parent, int start, int end)

Protected Functions

void beginInsertColumns(const QModelIndex & parent, int first, int last)
void beginInsertRows(const QModelIndex & parent, int first, int last)
bool beginMoveColumns(const QModelIndex & sourceParent, int sourceFirst, int sourceLast, const QModelIndex & destinationParent, int destinationChild)
bool beginMoveRows(const QModelIndex & sourceParent, int sourceFirst, int sourceLast, const QModelIndex & destinationParent, int destinationChild)
void beginRemoveColumns(const QModelIndex & parent, int first, int last)
void beginRemoveRows(const QModelIndex & parent, int first, int last)
void beginResetModel()
void changePersistentIndex(const QModelIndex & from, const QModelIndex & to)
void changePersistentIndexList(const QModelIndexList & from, const QModelIndexList & to)
QModelIndex createIndex(int row, int column, void * ptr = 0) const
QModelIndex createIndex(int row, int column, quint32 id) const
void endInsertColumns()
void endInsertRows()
void endMoveColumns()
void endMoveRows()
void endRemoveColumns()
void endRemoveRows()
void endResetModel()
QModelIndexList persistentIndexList() const
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 11 static public members inherited from QObject

Detailed Description

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 provides the 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.

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 = QModelIndex()) const [virtual]

Reimplemented from QAbstractItemModel::columnCount().

Returns the number of columns for the given parent.

See also QAbstractItemModel::columnCount().

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

Reimplemented from QAbstractItemModel::data().

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

See also setData().

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

Reimplemented from QAbstractItemModel::dropMimeData().

Returns true if the model accepts the data dropped onto an attached view for the specified action; otherwise returns false.

The parent, row, and 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) [virtual]

Reimplemented from 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.

See also QAbstractItemModel::fetchMore().

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

Reimplemented from QAbstractItemModel::flags().

Returns the item flags for the given index.

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

Reimplemented from QAbstractItemModel::hasChildren().

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

See also QAbstractItemModel::hasChildren().

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

Reimplemented from QAbstractItemModel::headerData().

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

See also setHeaderData().

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

Reimplemented from QAbstractItemModel::index().

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

See also QAbstractItemModel::index().

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

Reimplemented from QAbstractItemModel::insertColumns().

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.

See also QAbstractItemModel::insertColumns().

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

Reimplemented from QAbstractItemModel::insertRows().

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.

See also 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 [virtual]

Reimplemented from QAbstractItemModel::match().

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]

Reimplemented from QAbstractItemModel::mimeData().

Returns MIME data for the specified indexes in the model.

QStringList QProxyModel::mimeTypes() const [virtual]

Reimplemented from 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.

See also setModel().

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

Reimplemented from QAbstractItemModel::parent().

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

void QProxyModel::revert() [virtual]

Reimplemented from QAbstractItemModel::revert().

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

Reimplemented from QAbstractItemModel::rowCount().

Returns the number of rows for the given parent.

See also QAbstractItemModel::rowCount().

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

Reimplemented from QAbstractItemModel::setData().

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.

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

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

Reimplemented from QAbstractItemModel::setHeaderData().

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

See also headerData() and QAbstractItemModel::setHeaderData().

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

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

See also model().

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

Reimplemented from QAbstractItemModel::sort().

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

See also QAbstractItemModel::sort().

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

Reimplemented from QAbstractItemModel::span().

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

bool QProxyModel::submit() [virtual]

Reimplemented from QAbstractItemModel::submit().

Qt::DropActions QProxyModel::supportedDropActions() const [virtual]

Reimplemented from 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.

See also l{dnd.html}{Drag and Drop}.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web