Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QAbstractItemModel Class Reference

Inheritance diagram for QAbstractItemModel:

QObject QAbstractListModel QAbstractProxyModel QAbstractTableModel QDirModel QProxyModel QStandardItemModel QStringListModel QSortFilterProxyModel QSqlQueryModel QSqlTableModel QSqlRelationalTableModel

List of all members.


Detailed Description

The QAbstractItemModel class provides the abstract interface for item model classes.

The QAbstractItemModel class defines the standard interface that item models must use to be able to interoperate with other components in the model/view architecture. It is not supposed to be instantiated directly. Instead, you should subclass it to create new models.

The QAbstractItemModel class is one of the {Model/View Classes} and is part of Qt's {Model/View Programming}{model/view framework}.

If you need a model to use with a QListView or a QTableView, you should consider subclassing QAbstractListModel or QAbstractTableModel instead of this class.

The underlying data model is exposed to views and delegates as a hierarchy of tables. If you don't make use of the hierarchy, then the model is a simple table of rows and columns. Each item has a unique index specified by a QModelIndex.

modelindex-no-parent.png

Every item of data that can be accessed via a model has an associated model index that is obtained using the index() function. Each index may have a sibling() index; child items have a parent() index.

Each item has a number of data elements associated with it, and each of these can be retrieved by specifying a role (see Qt::ItemDataRole) to the model's data() function. Data for all available roles can be obtained at the same time using the itemData() function.

Data for each role is set using a particular Qt::ItemDataRole. Data for individual roles are set individually with setData(), or they can be set for all roles with setItemData().

Items can be queried with flags() (see Qt::ItemFlag) to see if they can be selected, dragged, or manipulated in other ways.

If an item has child objects, hasChildren() returns true for the corresponding index.

The model has a rowCount() and a columnCount() for each level of the hierarchy. Rows and columns can be inserted and removed with insertRows(), insertColumns(), removeRows(), and removeColumns().

The model emits signals to indicate changes. For example, dataChanged() is emitted whenever items of data made available by the model are changed. Changes to the headers supplied by the model cause headerDataChanged() to be emitted. If the structure of the underlying data changes, the model can emit layoutChanged() to indicate to any attached views that they should redisplay any items shown, taking the new structure into account.

The items available through the model can be searched for particular data using the match() function.

If the model is sortable, it can be sorted with sort().

Definition at line 148 of file qabstractitemmodel.h.


Public Slots

void deleteLater ()
virtual void revert ()
virtual bool submit ()

Signals

void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
void destroyed (QObject *=0)
void headerDataChanged (Qt::Orientation orientation, int first, int last)
void layoutAboutToBeChanged ()
void layoutChanged ()

Public Member Functions

bool blockSignals (bool b)
virtual QModelIndex buddy (const QModelIndex &index) const
virtual bool canFetchMore (const QModelIndex &parent) const
const QObjectListchildren () const
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const =0
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const =0
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
void dumpObjectInfo ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
virtual bool event (QEvent *)
virtual bool eventFilter (QObject *, QEvent *)
virtual void fetchMore (const QModelIndex &parent)
template<typename T>
findChild (const QString &name=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &name=QString()) const
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 inherits (const char *classname) const
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())
void installEventFilter (QObject *)
bool isWidgetType () const
virtual QMap< int, QVariantitemData (const QModelIndex &index) const
void killTimer (int id)
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 QMimeDatamimeData (const QModelIndexList &indexes) const
virtual QStringList mimeTypes () const
void moveToThread (QThread *thread)
QString objectName () const
QObjectparent () const
virtual QModelIndex parent (const QModelIndex &child) const =0
QVariant property (const char *name) const
 QAbstractItemModel (QObject *parent=0)
bool removeColumn (int column, const QModelIndex &parent=QModelIndex())
virtual bool removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
void removeEventFilter (QObject *)
bool removeRow (int row, const QModelIndex &parent=QModelIndex())
virtual bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
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)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setSupportedDragActions (Qt::DropActions)
void setUserData (uint id, QObjectUserData *data)
QModelIndex sibling (int row, int column, const QModelIndex &idx) const
bool signalsBlocked () const
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
virtual QSize span (const QModelIndex &index) const
int startTimer (int interval)
Qt::DropActions supportedDragActions () const
virtual Qt::DropActions supportedDropActions () const
QThreadthread () const
QObjectUserData * userData (uint id) const
virtual ~QAbstractItemModel ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static uint registerUserData ()

Protected Member Functions

void beginInsertColumns (const QModelIndex &parent, int first, int last)
void beginInsertRows (const QModelIndex &parent, int first, int last)
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
void beginRemoveRows (const QModelIndex &parent, int first, int last)
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
QModelIndex createIndex (int row, int column, quint32 id) const
QModelIndex createIndex (int row, int column, int id) const
QModelIndex createIndex (int row, int column, void *data=0) const
virtual void customEvent (QEvent *)
bool decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream)
virtual void disconnectNotify (const char *signal)
void encodeData (const QModelIndexList &indexes, QDataStream &stream) const
void endInsertColumns ()
void endInsertRows ()
void endRemoveColumns ()
void endRemoveRows ()
QModelIndexList persistentIndexList () const
 QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0)
int receivers (const char *signal) const
void reset ()
QObjectsender () const
virtual void timerEvent (QTimerEvent *)

Protected Attributes

QObjectData * d_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject

Properties

QString objectName
 the name of this object

Private Member Functions

void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
void columnsInserted (const QModelIndex &parent, int first, int last)
void columnsRemoved (const QModelIndex &parent, int first, int last)
void modelAboutToBeReset ()
void modelReset ()
void rowsAboutToBeInserted (const QModelIndex &parent, int first, int last)
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
void rowsInserted (const QModelIndex &parent, int first, int last)
void rowsRemoved (const QModelIndex &parent, int first, int last)

Friends

class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QPersistentModelIndexData
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name=QString(), T dummy=0)
qFindChild (const QObject *obj, const QString &name)
QList< T > qFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > qFindChildren (const QObject *obj, const QString &name)
T * qobject_cast (QObject *object)
 QObjectList
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index