This class is used as an index into item models derived from QAbstractItemModel. The index is used by item views, delegates, and selection models to locate an item in the model.
New QModelIndex objects are created by the model using the QAbstractItemModel::createIndex() function. An invalid model index can be constructed with the QModelIndex constructor. Invalid indexes are often used as parent indexes when referring to top-level items in a model.
Model indexes refer to items in models, and contain all the information required to specify their locations in those models. Each index is located in a given row and column, and may have a parent index; use row(), column(), and parent() to obtain this information. Each top-level item in a model is represented by a model index that does not have a parent index - in this case, parent() will return an invalid model index, equivalent to an index constructed with the zero argument form of the QModelIndex() constructor.
To obtain a model index that refers to an existing item in a model, call QAbstractItemModel::index() with the required row and column values, and the model index of the parent. When referring to top-level items in a model, supply QModelIndex() as the parent index.
The model() function returns the model that the index references as a QAbstractItemModel. The child() function is used to examine the items held beneath the index in the model. The sibling() function allows you to traverse items in the model on the same level as the index.
Model indexes can become invalid over time so they should be used immediately and then discarded. If you need to keep a model index over time use a QPersistentModelIndex.
Public Member Functions
|QModelIndex||child (int row, int column) const|
|int||column () const|
|QVariant||data (int role=Qt::DisplayRole) const|
|qint64||internalId () const|
|void *||internalPointer () const|
|bool||isValid () const|
|const QAbstractItemModel *||model () const|
|bool||operator!= (const QModelIndex &other) const|
|bool||operator< (const QModelIndex &other) const|
|bool||operator== (const QModelIndex &other) const|
|QModelIndex||parent () const|
|QModelIndex (const QModelIndex &other)|
|int||row () const|
|QModelIndex||sibling (int row, int column) const|
Private Member Functions
|QModelIndex (int row, int column, void *ptr, const QAbstractItemModel *model)|
|const QAbstractItemModel *||m|
|(Note that these are not member functions.) |