
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQAbstractTableModel class provides an abstract model that can be subclassed to create table models.More...
| Header: | #include <QAbstractTableModel> |
| Inherits: | QAbstractItemModel |
| Inherited By: |
| QAbstractTableModel(QObject * parent = 0) | |
| ~QAbstractTableModel() |
| 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 |
TheQAbstractTableModel 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 thanQAbstractItemModel, it is not suitable for use with tree views, although it can be used to provide data to aQListView. If you need to represent a simple list of items, and only need a model to contain a single column of data, subclassing theQAbstractListModel may be more appropriate.
TherowCount() andcolumnCount() functions return the dimensions of the table. To retrieve a model index corresponding to an item in the model, useindex() and provide only the row and column numbers.
When subclassingQAbstractTableModel, you must implementrowCount(),columnCount(), anddata(). Default implementations of theindex() andparent() functions are provided byQAbstractTableModel. Well behaved models will also implementheaderData().
Editable models need to implementsetData(), and implementflags() to return a value containingQt::ItemIsEditable.
Models that provide interfaces to resizable data structures can provide implementations ofinsertRows(),removeRows(),insertColumns(), andremoveColumns(). 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 theModel Subclassing Reference.
See alsoModel Classes,QAbstractItemModel,QAbstractListModel, andPixelator Example.
Constructs an abstract table model for the givenparent.
Destroys the abstract table model.
[virtual]bool QAbstractTableModel::dropMimeData(constQMimeData * data,Qt::DropAction action,int row,int column, constQModelIndex & parent)Reimplemented fromQAbstractItemModel::dropMimeData().
[virtual]QModelIndex QAbstractTableModel::index(int row,int column, constQModelIndex & parent = QModelIndex()) constReimplemented fromQAbstractItemModel::index().
Returns the index of the data inrow andcolumn withparent.
See alsoparent().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.