QAbstractTableModel Class
The QAbstractTableModel class provides an abstract model that can be subclassed to create table models. More...
#include <QAbstractTableModel> Inherits: QAbstractItemModel.
Inherited by: QSqlQueryModel.
Public Functions
| QAbstractItemModel(QObject * parent = 0) |
| QAbstractTableModel(QObject * parent = 0) |
virtual | ~QAbstractItemModel() |
| ~QAbstractTableModel() |
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 |
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) |
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 bool | dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) |
virtual QModelIndex | index(int row, int column, const QModelIndex & parent = QModelIndex()) const |
- 31 public functions inherited from QObject
Public Slots
- 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 QAbstractTableModel class provides an abstract model that can be subclassed to create table models.
QAbstractTableModel provides a standard interface for models that represent their data as a two-dimensional array of items. It is not used directly, but must be subclassed.
Since the model provides a more specialized interface than QAbstractItemModel, it is not suitable for use with tree views, although it can be used to provide data to a QListView. If you need to represent a simple list of items, and only need a model to contain a single column of data, subclassing the QAbstractListModel may be more appropriate.
The rowCount() and columnCount() functions return the dimensions of the table. To retrieve a model index corresponding to an item in the model, use index() and provide only the row and column numbers.
Subclassing
When subclassing QAbstractTableModel, you must implement rowCount(), columnCount(), and data(). Default implementations of the index() and parent() functions are provided by QAbstractTableModel. Well behaved models will also implement headerData().
Editable models need to implement setData(), and implement flags() to return a value containing Qt::ItemIsEditable.
Models that provide interfaces to resizable data structures can provide implementations of insertRows(), removeRows(), insertColumns(), and removeColumns(). When implementing these functions, it is important to call the appropriate functions so that all connected views are aware of any changes:
Note: Some general guidelines for subclassing models are available in the Model Subclassing Reference.
See also Model Classes, QAbstractItemModel, QAbstractListModel, and Pixelator Example.
Member Function Documentation
QAbstractTableModel::QAbstractTableModel(QObject * parent = 0)
Constructs an abstract table model for the given parent.
QAbstractTableModel::~QAbstractTableModel()
Destroys the abstract table model.
bool QAbstractTableModel::dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) [virtual]
Reimplemented from QAbstractItemModel::dropMimeData().
QModelIndex QAbstractTableModel::index(int row, int column, const QModelIndex & parent = QModelIndex()) const [virtual]
Reimplemented from QAbstractItemModel::index().
Returns the index of the data in row and column with parent.
See also parent().
|