Skip to content

PythonQt.Qt.QModelIndex

QModelIndex

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

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 items held under the index in the model. The sibling() function allows you to traverse items in the model on the same level as the index.

Note: Model indexes should be used immediately and then discarded. You should not rely on indexes to remain valid after calling model functions that change the structure of the model or delete items. If you need to keep a model index over time use a QPersistentModelIndex.

Source: https://doc.qt.io/archives/qt-5.15/qmodelindex.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
child function (self, row: int, column: int) -> Any X.child(row, column) -> PythonQt.QtCore.QModelIndex (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
column function (self) -> int X.column() -> int (shared captured text)
data function (self, role: int) -> Any X.data(role) -> object (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
flags function (self) -> Any Returns the flags for the item referred to by the index. (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
internalId function (self) -> int X.internalId() -> int (shared captured text)
internalPointer function (self) -> int Returns a void * pointer used by the model to associate the index with the internal data structure. (shared captured text)
isValid function (self) -> bool X.isValid() -> bool (shared captured text)
model function (self) -> Any X.model() -> PythonQt.QtCore.QAbstractItemModel (shared captured text)
parent function (self) -> Any X.parent() -> PythonQt.QtCore.QModelIndex (shared captured text)
row function (self) -> int X.row() -> int (shared captured text)
sibling function (self, row: int, column: int) -> Any X.sibling(row, column) -> PythonQt.QtCore.QModelIndex (shared captured text)