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  · 

QAbstractProxyModel Class

The QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks. More...

 #include <QAbstractProxyModel>

Inherits: QAbstractItemModel.

Inherited by: QIdentityProxyModel and QSortFilterProxyModel.

This class was introduced in Qt 4.1.

Public Functions

QAbstractItemModel(QObject * parent = 0)
QAbstractProxyModel(QObject * parent = 0)
virtual ~QAbstractItemModel()
~QAbstractProxyModel()
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 QModelIndex mapFromSource(const QModelIndex & sourceIndex) const = 0
virtual QItemSelection mapSelectionFromSource(const QItemSelection & sourceSelection) const
virtual QItemSelection mapSelectionToSource(const QItemSelection & proxySelection) const
virtual QModelIndex mapToSource(const QModelIndex & proxyIndex) const = 0
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
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 setSourceModel(QAbstractItemModel * sourceModel)
QModelIndex sibling(int row, int column, const QModelIndex & index) const
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder)
QAbstractItemModel * sourceModel() const
virtual QSize span(const QModelIndex & index) const
virtual Qt::DropActions supportedDragActions() const
virtual Qt::DropActions supportedDropActions() const

Reimplemented Public Functions

virtual QModelIndex buddy(const QModelIndex & index) const
virtual bool canFetchMore(const QModelIndex & parent) const
virtual QVariant data(const QModelIndex & proxyIndex, int role = Qt::DisplayRole) const
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) const
virtual QMap<int, QVariant> itemData(const QModelIndex & proxyIndex) const
virtual QMimeData * mimeData(const QModelIndexList & indexes) const
virtual QStringList mimeTypes() const
virtual void revert()
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 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 QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks.

This class defines the standard interface that proxy models must use to be able to interoperate correctly with other model/view components. It is not supposed to be instantiated directly.

All standard proxy models are derived from the QAbstractProxyModel class. If you need to create a new proxy model class, it is usually better to subclass an existing class that provides the closest behavior to the one you want to provide.

Proxy models that filter or sort items of data from a source model should be created by using or subclassing QSortFilterProxyModel.

To subclass QAbstractProxyModel, you need to implement mapFromSource() and mapToSource(). The mapSelectionFromSource() and mapSelectionToSource() functions only need to be reimplemented if you need a behavior different from the default behavior.

Note: If the source model is deleted or no source model is specified, the proxy model operates on a empty placeholder model.

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

Member Function Documentation

QAbstractProxyModel::QAbstractProxyModel(QObject * parent = 0)

Constructs a proxy model with the given parent.

QAbstractProxyModel::~QAbstractProxyModel()

Destroys the proxy model.

QModelIndex QAbstractProxyModel::buddy(const QModelIndex & index) const [virtual]

Reimplemented from QAbstractItemModel::buddy().

bool QAbstractProxyModel::canFetchMore(const QModelIndex & parent) const [virtual]

Reimplemented from QAbstractItemModel::canFetchMore().

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

Reimplemented from QAbstractItemModel::data().

See also setData().

void QAbstractProxyModel::fetchMore(const QModelIndex & parent) [virtual]

Reimplemented from QAbstractItemModel::fetchMore().

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

Reimplemented from QAbstractItemModel::flags().

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

Reimplemented from QAbstractItemModel::hasChildren().

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

Reimplemented from QAbstractItemModel::headerData().

See also setHeaderData().

QMap<int, QVariant> QAbstractProxyModel::itemData(const QModelIndex & proxyIndex) const [virtual]

Reimplemented from QAbstractItemModel::itemData().

See also setItemData().

QModelIndex QAbstractProxyModel::mapFromSource(const QModelIndex & sourceIndex) const [pure virtual]

Reimplement this function to return the model index in the proxy model that corresponds to the sourceIndex from the source model.

See also mapToSource().

QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection & sourceSelection) const [virtual]

Returns a proxy selection mapped from the specified sourceSelection.

Reimplement this method to map source selections to proxy selections.

QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection & proxySelection) const [virtual]

Returns a source selection mapped from the specified proxySelection.

Reimplement this method to map proxy selections to source selections.

QModelIndex QAbstractProxyModel::mapToSource(const QModelIndex & proxyIndex) const [pure virtual]

Reimplement this function to return the model index in the source model that corresponds to the proxyIndex in the proxy model.

See also mapFromSource().

QMimeData * QAbstractProxyModel::mimeData(const QModelIndexList & indexes) const [virtual]

Reimplemented from QAbstractItemModel::mimeData().

QStringList QAbstractProxyModel::mimeTypes() const [virtual]

Reimplemented from QAbstractItemModel::mimeTypes().

void QAbstractProxyModel::revert() [virtual]

Reimplemented from QAbstractItemModel::revert().

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

Reimplemented from QAbstractItemModel::setData().

See also data().

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

Reimplemented from QAbstractItemModel::setHeaderData().

See also headerData().

bool QAbstractProxyModel::setItemData(const QModelIndex & index, const QMap<int, QVariant> & roles) [virtual]

Reimplemented from QAbstractItemModel::setItemData().

See also itemData().

void QAbstractProxyModel::setSourceModel(QAbstractItemModel * sourceModel) [virtual]

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

See also sourceModel().

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

Reimplemented from QAbstractItemModel::sort().

QAbstractItemModel * QAbstractProxyModel::sourceModel() const

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

See also setSourceModel().

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

Reimplemented from QAbstractItemModel::span().

bool QAbstractProxyModel::submit() [virtual]

Reimplemented from QAbstractItemModel::submit().

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

Reimplemented from QAbstractItemModel::supportedDropActions().

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