class QPersistentModelIndex

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

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

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.

Note

You cannot store a QStandardItemModel’s QPersistentModelIndex in one of the model’s items.

__init__()
__init__(index)
Parameters:

indexQModelIndex

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

__init__(other)
Parameters:

otherQPersistentModelIndex

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

column()
Return type:

int

Returns the column this persistent model index refers to.

constInternalPointer()
Return type:

void

data([role=Qt.DisplayRole])
Parameters:

role – int

Return type:

object

Returns the data for the given role for the item referred to by the index, or a default-constructed QVariant if this persistent model index is invalid .

flags()
Return type:

Combination of ItemFlag

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

internalId()
Return type:

quintptr

internalPointer()
Return type:

void

isValid()
Return type:

bool

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.

model()
Return type:

QAbstractItemModel

Returns the model that the index belongs to.

multiData(roleDataSpan)
Parameters:

roleDataSpanQModelRoleDataSpan

Populates the given roleDataSpan for the item referred to by the index.

__ne__(rhs)
Parameters:

rhsQModelIndex

Return type:

bool

Returns true if lhs persistent model index does not refer to the same location as the rhs model index; otherwise returns false.

__ne__(rhs)
Parameters:

rhsQPersistentModelIndex

Return type:

bool

Returns true if lhs persistent model index is not equal to the rhs persistent model index; otherwise returns false.

__lt__(rhs)
Parameters:

rhsQModelIndex

Return type:

bool

__lt__(rhs)
Parameters:

rhsQPersistentModelIndex

Return type:

bool

Returns true if lhs persistent model index is smaller than the rhs persistent model index; otherwise returns false.

The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another persistent model index.

__le__(rhs)
Parameters:

rhsQModelIndex

Return type:

bool

__le__(rhs)
Parameters:

rhsQPersistentModelIndex

Return type:

bool

__eq__(rhs)
Parameters:

rhsQModelIndex

Return type:

bool

Returns true if lhs persistent model index refers to the same location as the rhs model index; otherwise returns false.

The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another model index.

__eq__(rhs)
Parameters:

rhsQPersistentModelIndex

Return type:

bool

Returns true if lhs persistent model index is equal to the rhs persistent model index; otherwise returns false.

The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another persistent model index.

__gt__(rhs)
Parameters:

rhsQModelIndex

Return type:

bool

__gt__(rhs)
Parameters:

rhsQPersistentModelIndex

Return type:

bool

__ge__(rhs)
Parameters:

rhsQModelIndex

Return type:

bool

__ge__(rhs)
Parameters:

rhsQPersistentModelIndex

Return type:

bool

parent()
Return type:

QModelIndex

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

See also

sibling() model()

row()
Return type:

int

Returns the row this persistent model index refers to.

sibling(row, column)
Parameters:
  • row – int

  • column – int

Return type:

QModelIndex

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

See also

parent()

swap(other)
Parameters:

otherQPersistentModelIndex

Swaps this persistent modelindex with other. This function is very fast and never fails.