PySide6.QtCore.QPersistentModelIndex¶
- class QPersistentModelIndex¶
The
QPersistentModelIndexclass is used to locate data in a data model.Details
A
QPersistentModelIndexis a model index that can be stored by an application, and later used to access information in a model. Unlike theQModelIndexclass, it is safe to store aQPersistentModelIndexsince 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
QPersistentModelIndexin one of the model’s items.See also
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
- __init__()¶
- __init__(index)
- Parameters:
index –
QModelIndex
Creates a new
QPersistentModelIndexthat is a copy of the modelindex.- __init__(other)
- Parameters:
other –
QPersistentModelIndex
Creates a new
QPersistentModelIndexthat is a copy of theotherpersistent model index.- column()¶
- Return type:
int
Returns the column this persistent model index refers to.
- data([role=Qt.DisplayRole])¶
- Parameters:
role – int
- Return type:
object
Returns the data for the given
rolefor the item referred to by the index, or a default-constructedQVariantif this persistent model index isinvalid.See also
Returns the flags for the item referred to by the index.
- internalId()¶
- Return type:
quintptr
- internalPointer()¶
- Return type:
void
- isValid()¶
- Return type:
bool
Returns
trueif this persistent model index is valid; otherwise returnsfalse.A valid index belongs to a model, and has non-negative row and column numbers.
- model()¶
- Return type:
Returns the model that the index belongs to.
- multiData(roleDataSpan)¶
- Parameters:
roleDataSpan –
QModelRoleDataSpan
Populates the given
roleDataSpanfor the item referred to by the index.See also
- __ne__(rhs)¶
- Parameters:
rhs –
QModelIndex- Return type:
bool
Returns
trueiflhspersistent model index does not refer to the same location as therhsmodel index; otherwise returnsfalse.- __ne__(rhs)
- Parameters:
rhs –
QPersistentModelIndex- Return type:
bool
Returns
trueiflhspersistent model index is not equal to therhspersistent model index; otherwise returnsfalse.- __lt__(rhs)¶
- Parameters:
rhs –
QModelIndex- Return type:
bool
- __lt__(rhs)
- Parameters:
rhs –
QPersistentModelIndex- Return type:
bool
Returns
trueiflhspersistent model index is smaller than therhspersistent model index; otherwise returnsfalse.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:
rhs –
QModelIndex- Return type:
bool
- __le__(rhs)
- Parameters:
rhs –
QPersistentModelIndex- Return type:
bool
- operator=(other)
- Parameters:
other –
QModelIndex- Return type:
Sets the persistent model index to refer to the same item in a model as the
othermodel index.- __eq__(rhs)¶
- Parameters:
rhs –
QModelIndex- Return type:
bool
Returns
trueiflhspersistent model index refers to the same location as therhsmodel index; otherwise returnsfalse.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:
rhs –
QPersistentModelIndex- Return type:
bool
Returns
trueiflhspersistent model index is equal to therhspersistent model index; otherwise returnsfalse.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:
rhs –
QModelIndex- Return type:
bool
- __gt__(rhs)
- Parameters:
rhs –
QPersistentModelIndex- Return type:
bool
- __ge__(rhs)¶
- Parameters:
rhs –
QModelIndex- Return type:
bool
- __ge__(rhs)
- Parameters:
rhs –
QPersistentModelIndex- Return type:
bool
- parent()¶
- Return type:
Returns the parent
QModelIndexfor this persistent index, or an invalidQModelIndexif it has no parent.- row()¶
- Return type:
int
Returns the row this persistent model index refers to.
- sibling(row, column)¶
- Parameters:
row – int
column – int
- Return type:
Returns the sibling at
rowandcolumnor an invalidQModelIndexif there is no sibling at this position.See also
- swap(other)¶
- Parameters:
other –
QPersistentModelIndex
Swaps this persistent modelindex with
other. This operation is very fast and never fails.