[][src]Struct qt_core::QModelIndex

#[repr(C)]
pub struct QModelIndex { /* fields omitted */ }

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

C++ class: QModelIndex.

C++ documentation:

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.

Methods

impl QModelIndex[src]

pub unsafe fn child(&self, row: c_int, column: c_int) -> CppBox<QModelIndex>[src]

Use QAbstractItemModel::index() instead.

Calls C++ function: QModelIndex QModelIndex::child(int row, int column) const.

C++ documentation:

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.

See also parent() and sibling().

pub unsafe fn column(&self) -> c_int[src]

Returns the column this model index refers to.

Calls C++ function: int QModelIndex::column() const.

C++ documentation:

Returns the column this model index refers to.

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<QModelIndex>>
) -> MutRef<QModelIndex>
[src]

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

Calls C++ function: QModelIndex& QModelIndex::operator=(const QModelIndex& other).

C++ documentation:

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.

pub unsafe fn data_1a(&self, role: c_int) -> CppBox<QVariant>[src]

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

Calls C++ function: QVariant QModelIndex::data(int role = …) const.

C++ documentation:

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

pub unsafe fn data_0a(&self) -> CppBox<QVariant>[src]

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

Calls C++ function: QVariant QModelIndex::data() const.

C++ documentation:

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

pub unsafe fn flags(&self) -> QFlags<ItemFlag>[src]

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

Calls C++ function: QFlags<Qt::ItemFlag> QModelIndex::flags() const.

C++ documentation:

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

This function was introduced in Qt 4.2.

pub unsafe fn internal_id(&self) -> usize[src]

Returns a quintptr used by the model to associate the index with the internal data structure.

Calls C++ function: quintptr QModelIndex::internalId() const.

C++ documentation:

Returns a quintptr used by the model to associate the index with the internal data structure.

See also QAbstractItemModel::createIndex().

pub unsafe fn internal_pointer(&self) -> MutPtr<c_void>[src]

Returns a void * pointer used by the model to associate the index with the internal data structure.

Calls C++ function: void* QModelIndex::internalPointer() const.

C++ documentation:

Returns a void * pointer used by the model to associate the index with the internal data structure.

See also QAbstractItemModel::createIndex().

pub unsafe fn is_valid(&self) -> bool[src]

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

Calls C++ function: bool QModelIndex::isValid() const.

C++ documentation:

Returns true if this 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().

pub unsafe fn model(&self) -> Ptr<QAbstractItemModel>[src]

Returns a pointer to the model containing the item that this index refers to.

Calls C++ function: const QAbstractItemModel* QModelIndex::model() const.

C++ documentation:

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.

pub unsafe fn new() -> CppBox<QModelIndex>[src]

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().

C++ documentation:

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.

pub unsafe fn new_copy(
    other: impl CastInto<Ref<QModelIndex>>
) -> CppBox<QModelIndex>
[src]

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

Calls C++ function: [constructor] void QModelIndex::QModelIndex(const QModelIndex& other).

C++ documentation:

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.

pub unsafe fn parent(&self) -> CppBox<QModelIndex>[src]

Returns the parent of the model index, or QModelIndex() if it has no parent.

Calls C++ function: QModelIndex QModelIndex::parent() const.

C++ documentation:

Returns the parent of the model index, or QModelIndex() if it has no parent.

See also sibling() and model().

pub unsafe fn row(&self) -> c_int[src]

Returns the row this model index refers to.

Calls C++ function: int QModelIndex::row() const.

C++ documentation:

Returns the row this model index refers to.

pub unsafe fn sibling(&self, row: c_int, column: c_int) -> CppBox<QModelIndex>[src]

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.

C++ documentation:

Returns the sibling at row and column. If there is no sibling at this position, an invalid QModelIndex is returned.

See also parent().

pub unsafe fn sibling_at_column(&self, column: c_int) -> CppBox<QModelIndex>[src]

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.

C++ documentation:

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().

This item is available if any(cpp_lib_version="5.11.3", cpp_lib_version="5.12.2", cpp_lib_version="5.13.0").

pub unsafe fn sibling_at_row(&self, row: c_int) -> CppBox<QModelIndex>[src]

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.

C++ documentation:

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().

This item is available if any(cpp_lib_version="5.11.3", cpp_lib_version="5.12.2", cpp_lib_version="5.13.0").

Trait Implementations

impl PartialEq<Ref<QModelIndex>> for QModelIndex[src]

fn eq(&self, other: &Ref<QModelIndex>) -> bool[src]

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.

C++ documentation:

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.

impl Lt<Ref<QModelIndex>> for QModelIndex[src]

unsafe fn lt(&self, other: &Ref<QModelIndex>) -> bool[src]

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.

C++ documentation:

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.

impl CppDeletable for QModelIndex[src]

unsafe fn delete(&mut self)[src]

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

Calls C++ function: [destructor] void QModelIndex::~QModelIndex().

C++ documentation:

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.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]