Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QModelIndex Class Reference

The QModelIndex class is used to locate data in a data model. More...

    #include <QModelIndex>

- List of all members, including inherited members

### Public Types

- enum SpecialValue { Null }

### Public Functions

- QModelIndex ( SpecialValue type = Null )
- QModelIndex ( const QModelIndex & other )
- ~QModelIndex ()
- int column () const
- bool isValid () const
- int row () const
- bool operator!= ( const QModelIndex & other ) const
- bool operator== ( const QModelIndex & other ) const

## Detailed Description

The QModelIndex class is used to locate data in a data model.

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. QModelIndex objects are created by the model.

An invalid model index can be constructed with the zero argument form of the QModelIndex() constructor. This is useful when referring to top-level items in a model.

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.

A model index has a row() and a column()

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

## Member Type Documentation

### enum QModelIndex::SpecialValue

This enum describes a special type of model index:

`QModelIndex::Null` | A model index to represent the parent of top-level table items.

## Member Function Documentation

### QModelIndex::QModelIndex ( SpecialValue type = Null )

Creates a new empty model index of the given type. By default, a `Null` model index is created. This type of model index is used as the parent index for top-level items in a model.

See also QAbstractItemModel.

### QModelIndex::QModelIndex ( const QModelIndex & other )

Creates a new model index that is a copy of the other model index.

### QModelIndex::~QModelIndex ()

Destroys the model index.

### int QModelIndex::column () const

Returns the column this model index refers to.

### bool QModelIndex::isValid () const

Returns true if this model index is valid; otherwise returns false.

### int QModelIndex::row () const

Returns the row this model index refers to.

### bool QModelIndex::operator!= ( const QModelIndex & other ) const

Returns true if this model index does not refer to the same location as the other model index; otherwise returns false.

### bool QModelIndex::operator== ( const QModelIndex & other ) const

Returns true if this model index refers to the same location as the other model index; otherwise returns false.