Struct qt_core::QModelIndex
source · #[repr(C)]pub struct QModelIndex { /* private fields */ }
Expand description
The QModelIndex class is used to locate data in a data model.
C++ class: QModelIndex
.
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.
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.
Implementations§
source§impl QModelIndex
impl QModelIndex
sourcepub unsafe fn child(&self, row: c_int, column: c_int) -> CppBox<QModelIndex>
pub unsafe fn child(&self, row: c_int, column: c_int) -> CppBox<QModelIndex>
Use QAbstractItemModel::index() instead.
Calls C++ function: QModelIndex QModelIndex::child(int row, int column) const
.
Use QAbstractItemModel::index() instead.
Returns the child of the model index that is stored in the given row and column.
Note: This function does not work for an invalid model index which is often used as the root index.
sourcepub unsafe fn column(&self) -> c_int
pub unsafe fn column(&self) -> c_int
Returns the column this model index refers to.
Calls C++ function: int QModelIndex::column() const
.
Returns the column this model index refers to.
sourcepub unsafe fn copy_from(
&self,
other: impl CastInto<Ref<QModelIndex>>
) -> Ref<QModelIndex>
pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QModelIndex>> ) -> Ref<QModelIndex>
The QModelIndex class is used to locate data in a data model.
Calls C++ function: QModelIndex& QModelIndex::operator=(const QModelIndex& other)
.
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.
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.
sourcepub unsafe fn data_1a(&self, role: c_int) -> CppBox<QVariant>
pub unsafe fn data_1a(&self, role: c_int) -> CppBox<QVariant>
Returns the data for the given role for the item referred to by the index.
Calls C++ function: QVariant QModelIndex::data(int role = …) const
.
Returns the data for the given role for the item referred to by the index.
sourcepub unsafe fn data_0a(&self) -> CppBox<QVariant>
pub unsafe fn data_0a(&self) -> CppBox<QVariant>
Returns the data for the given role for the item referred to by the index.
Calls C++ function: QVariant QModelIndex::data() const
.
Returns the data for the given role for the item referred to by the index.
sourcepub unsafe fn flags(&self) -> QFlags<ItemFlag>
pub unsafe fn flags(&self) -> QFlags<ItemFlag>
Returns the flags for the item referred to by the index.
Calls C++ function: QFlags<Qt::ItemFlag> QModelIndex::flags() const
.
Returns the flags for the item referred to by the index.
This function was introduced in Qt 4.2.
sourcepub unsafe fn internal_id(&self) -> usize
pub unsafe fn internal_id(&self) -> usize
Returns a quintptr
used by the model to associate the index with the internal data structure.
Calls C++ function: quintptr QModelIndex::internalId() const
.
Returns a quintptr
used by the model to associate the index with the internal data structure.
See also QAbstractItemModel::createIndex().
sourcepub unsafe fn internal_pointer(&self) -> *mut c_void
pub unsafe fn internal_pointer(&self) -> *mut c_void
Returns a void
*
pointer used by the model to associate the index with the internal data structure.
Calls C++ function: void* QModelIndex::internalPointer() const
.
Returns a void
*
pointer used by the model to associate the index with the internal data structure.
See also QAbstractItemModel::createIndex().
sourcepub unsafe fn is_valid(&self) -> bool
pub unsafe fn is_valid(&self) -> bool
Returns true
if this model index is valid; otherwise returns false
.
Calls C++ function: bool QModelIndex::isValid() const
.
sourcepub unsafe fn model(&self) -> QPtr<QAbstractItemModel>
pub unsafe fn model(&self) -> QPtr<QAbstractItemModel>
Returns a pointer to the model containing the item that this index refers to.
Calls C++ function: const QAbstractItemModel* QModelIndex::model() const
.
Returns a pointer to the model containing the item that this index refers to.
A const pointer to the model is returned because calls to non-const functions of the model might invalidate the model index and possibly crash your application.
sourcepub unsafe fn new() -> CppBox<QModelIndex>
pub unsafe fn new() -> CppBox<QModelIndex>
Creates a new empty model index. This type of model index is used to indicate that the position in the model is invalid.
Calls C++ function: [constructor] void QModelIndex::QModelIndex()
.
Creates a new empty model index. This type of model index is used to indicate that the position in the model is invalid.
See also isValid() and QAbstractItemModel.
sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<QModelIndex>>
) -> CppBox<QModelIndex>
pub unsafe fn new_copy( other: impl CastInto<Ref<QModelIndex>> ) -> CppBox<QModelIndex>
The QModelIndex class is used to locate data in a data model.
Calls C++ function: [constructor] void QModelIndex::QModelIndex(const QModelIndex& other)
.
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.
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.
sourcepub unsafe fn parent(&self) -> CppBox<QModelIndex>
pub unsafe fn parent(&self) -> CppBox<QModelIndex>
Returns the parent of the model index, or QModelIndex() if it has no parent.
Calls C++ function: QModelIndex QModelIndex::parent() const
.
Returns the parent of the model index, or QModelIndex() if it has no parent.
sourcepub unsafe fn row(&self) -> c_int
pub unsafe fn row(&self) -> c_int
Returns the row this model index refers to.
Calls C++ function: int QModelIndex::row() const
.
Returns the row this model index refers to.
sourcepub unsafe fn sibling(&self, row: c_int, column: c_int) -> CppBox<QModelIndex>
pub unsafe fn sibling(&self, row: c_int, column: c_int) -> CppBox<QModelIndex>
Returns the sibling at row and column. If there is no sibling at this position, an invalid QModelIndex is returned.
Calls C++ function: QModelIndex QModelIndex::sibling(int row, int column) const
.
Returns the sibling at row and column. If there is no sibling at this position, an invalid QModelIndex is returned.
See also parent().
sourcepub unsafe fn sibling_at_column(&self, column: c_int) -> CppBox<QModelIndex>
Available on cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.
pub unsafe fn sibling_at_column(&self, column: c_int) -> CppBox<QModelIndex>
cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.Returns the sibling at column for the current row. If there is no sibling at this position, an invalid QModelIndex is returned.
Calls C++ function: QModelIndex QModelIndex::siblingAtColumn(int column) const
.
Returns the sibling at column for the current row. If there is no sibling at this position, an invalid QModelIndex is returned.
This function was introduced in Qt 5.11.
See also sibling() and siblingAtRow().
sourcepub unsafe fn sibling_at_row(&self, row: c_int) -> CppBox<QModelIndex>
Available on cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.
pub unsafe fn sibling_at_row(&self, row: c_int) -> CppBox<QModelIndex>
cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.Returns the sibling at row for the current column. If there is no sibling at this position, an invalid QModelIndex is returned.
Calls C++ function: QModelIndex QModelIndex::siblingAtRow(int row) const
.
Returns the sibling at row for the current column. If there is no sibling at this position, an invalid QModelIndex is returned.
This function was introduced in Qt 5.11.
See also sibling() and siblingAtColumn().
Trait Implementations§
source§impl CppDeletable for QModelIndex
impl CppDeletable for QModelIndex
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QModelIndex class is used to locate data in a data model.
Calls C++ function: [destructor] void QModelIndex::~QModelIndex()
.
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.
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§impl Lt<Ref<QModelIndex>> for QModelIndex
impl Lt<Ref<QModelIndex>> for QModelIndex
source§unsafe fn lt(&self, other: &Ref<QModelIndex>) -> bool
unsafe fn lt(&self, other: &Ref<QModelIndex>) -> bool
Returns true
if this model index is smaller than the other model index; otherwise returns false
.
Calls C++ function: bool QModelIndex::operator<(const QModelIndex& other) const
.
Returns true
if this model index is smaller than the other model index; otherwise returns false
.
The less than calculation is not directly useful to developers - the way that indexes with different parents compare is not defined. This operator only exists so that the class can be used with QMap.
This function was introduced in Qt 4.1.
source§impl PartialEq<Ref<QModelIndex>> for QModelIndex
impl PartialEq<Ref<QModelIndex>> for QModelIndex
source§fn eq(&self, other: &Ref<QModelIndex>) -> bool
fn eq(&self, other: &Ref<QModelIndex>) -> bool
Returns true
if this model index refers to the same location as the other model index; otherwise returns false
.
Calls C++ function: 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
.
All values in the model index are used when comparing with another model index.