|  | Home · All Classes · Modules

# QPersistentModelIndex Class Reference
[QtCore module]

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

### Methods

- __init__ (self)
- __init__ (self, QModelIndex)
- __init__ (self, QPersistentModelIndex)
- QModelIndex child (self, int, int)
- int column (self)
- QVariantQVariant data (self, int role = Qt.DisplayRole)
- Qt.ItemFlags flags (self)
- bool isValid (self)
- QAbstractItemModel model (self)
- QModelIndex parent (self)
- int row (self)
- QModelIndex sibling (self, int, int)

### Special Methods

- bool __eq__ (self, QPersistentModelIndex)
- bool __eq__ (self, QModelIndex)
- bool __ge__ (self, QPersistentModelIndex)
- int __hash__ (self)
- bool __lt__ (self, QPersistentModelIndex)
- bool __ne__ (self, QPersistentModelIndex)
- bool __ne__ (self, QModelIndex)

## Detailed Description

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

A QPersistentModelIndex is a model index that can be stored by an application, and later used to access information in a model. Unlike the QModelIndex class, it is safe to store a QPersistentModelIndex since the model will ensure that references to items will continue to be valid as long as they can be accessed by the model.

It is good practice to check that persistent model indexes are valid before using them.

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

## Method Documentation

### QPersistentModelIndex.__init__ (self)

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

### QPersistentModelIndex.__init__ (self, QModelIndex)

### QPersistentModelIndex.__init__ (self, QPersistentModelIndex)

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

### QModelIndex QPersistentModelIndex.child (self, int, int)

Returns the child of the model index that is stored in the given row and column.

See also parent() and sibling().

### int QPersistentModelIndex.column (self)

Returns the column this persistent model index refers to.

### QVariantQVariant QPersistentModelIndex.data (self, int role = Qt.DisplayRole)

Returns the data for the given role for the item referred to by the index.

See also Qt.ItemDataRole and QAbstractItemModel.setData().

### Qt.ItemFlags QPersistentModelIndex.flags (self)

Returns the flags for the item referred to by the index.

This function was introduced in Qt 4.2.

### bool QPersistentModelIndex.isValid (self)

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

A valid index belongs to a model, and has non-negative row and column numbers.

See also model(), row(), and column().

### QAbstractItemModel QPersistentModelIndex.model (self)

Returns the model that the index belongs to.

### QModelIndex QPersistentModelIndex.parent (self)

Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no parent.

See also child(), sibling(), and model().

### int QPersistentModelIndex.row (self)

Returns the row this persistent model index refers to.

### QModelIndex QPersistentModelIndex.sibling (self, int, int)

Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this position.

See also parent() and child().

### bool QPersistentModelIndex.__eq__ (self, QPersistentModelIndex)

### bool QPersistentModelIndex.__eq__ (self, QModelIndex)

### bool QPersistentModelIndex.__ge__ (self, QPersistentModelIndex)

### int QPersistentModelIndex.__hash__ (self)

### bool QPersistentModelIndex.__lt__ (self, QPersistentModelIndex)

### bool QPersistentModelIndex.__ne__ (self, QPersistentModelIndex)

### bool QPersistentModelIndex.__ne__ (self, QModelIndex)