QPersistentModelIndex 类用于在数据模型中定位数据。 更多...
| 头: |
#include <QPersistentModelIndex>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
|
| qmake: |
QT += core
|
此类 强烈可比较 .
此类 强烈可比较 with QModelIndex .
| QPersistentModelIndex (const QModelIndex & index ) | |
| QPersistentModelIndex (const QPersistentModelIndex & other ) | |
| QPersistentModelIndex (QPersistentModelIndex && other ) | |
| int | column () const |
| QVariant | data (int role = Qt::DisplayRole) const |
| Qt::ItemFlags | flags () const |
| bool | isValid () const |
| const QAbstractItemModel * | model () const |
(从 6.0 起)
void
|
multiData (QModelRoleDataSpan roleDataSpan ) const |
| QModelIndex | parent () const |
| int | row () const |
| QModelIndex | sibling (int row , int column ) const |
| void | swap (QPersistentModelIndex & other ) |
| QModelIndex | operator QModelIndex () const |
| QPersistentModelIndex & | operator= (QPersistentModelIndex && other ) |
| QPersistentModelIndex & | operator= (const QModelIndex & other ) |
| QPersistentModelIndex & | operator= (const QPersistentModelIndex & other ) |
| size_t | qHash (const QPersistentModelIndex & key , size_t seed = 0) |
| bool | operator!= (const QPersistentModelIndex & lhs , const QModelIndex & rhs ) |
| bool | operator!= (const QPersistentModelIndex & lhs , const QPersistentModelIndex & rhs ) |
| bool | operator< (const QPersistentModelIndex & lhs , const QPersistentModelIndex & rhs ) |
| bool | operator== (const QPersistentModelIndex & lhs , const QModelIndex & rhs ) |
| bool | operator== (const QPersistentModelIndex & lhs , const QPersistentModelIndex & rhs ) |
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.
注意: You cannot store a QStandardItemModel 's QPersistentModelIndex in one of the model's items.
另请参阅 模型/视图编程 , QModelIndex ,和 QAbstractItemModel .
Creates a new QPersistentModelIndex that is a copy of the model index .
Creates a new QPersistentModelIndex that is a copy of the other persistent model index.
[noexcept]
QPersistentModelIndex::
QPersistentModelIndex
(
QPersistentModelIndex
&&
other
)
Move-constructs a QPersistentModelIndex instance, making it point at the same object that other 所指向的。
Returns the column this persistent model index refers to.
返回数据为给定 role for the item referred to by the index, or a default-constructed QVariant if this persistent model index is 无效 .
另请参阅 Qt::ItemDataRole and QAbstractItemModel::setData ().
返回由索引所引用的项标志。
返回
true
若此持久模型索引有效;否则返回
false
.
有效索引属于模型,且拥有非负行号和列号。
另请参阅 model (), row (),和 column ().
返回索引所属的模型。
[since 6.0]
void
QPersistentModelIndex::
multiData
(
QModelRoleDataSpan
roleDataSpan
) const
Populates the given roleDataSpan 对于索引所引用的项。
该函数在 Qt 6.0 引入。
另请参阅 Qt::ItemDataRole and QAbstractItemModel::setData ().
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no parent.
Returns the row this persistent model index refers to.
返回同级在 row and column or an invalid QModelIndex if there is no sibling at this position.
另请参阅 parent ().
[noexcept]
void
QPersistentModelIndex::
swap
(
QPersistentModelIndex
&
other
)
Swaps this persistent modelindex with other 。此操作非常快且从不失败。
Cast operator that returns a QModelIndex .
[noexcept]
QPersistentModelIndex
&QPersistentModelIndex::
operator=
(
QPersistentModelIndex
&&
other
)
移动赋值 other 到此 QPersistentModelIndex 实例。
Sets the persistent model index to refer to the same item in a model as the other 模型索引。
Sets the persistent model index to refer to the same item in a model as the other persistent model index.
[noexcept]
size_t
qHash
(const
QPersistentModelIndex
&
key
,
size_t
seed
= 0)
返回哈希值为 key ,使用 seed 做计算种子。
[noexcept]
bool
operator!=
(const
QPersistentModelIndex
&
lhs
, const
QModelIndex
&
rhs
)
返回
true
if
lhs
persistent model index does not refer to the same location as the
rhs
模型索引;否则返回
false
.
[noexcept]
bool
operator!=
(const
QPersistentModelIndex
&
lhs
, const
QPersistentModelIndex
&
rhs
)
返回
true
if
lhs
persistent model index is not equal to the
rhs
persistent model index; otherwise returns
false
.
[noexcept]
bool
operator<
(const
QPersistentModelIndex
&
lhs
, const
QPersistentModelIndex
&
rhs
)
返回
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.
[noexcept]
bool
operator==
(const
QPersistentModelIndex
&
lhs
, const
QModelIndex
&
rhs
)
返回
true
if
lhs
persistent model index refers to the same location as the
rhs
模型索引;否则返回
false
.
The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another model index.
[noexcept]
bool
operator==
(const
QPersistentModelIndex
&
lhs
, const
QPersistentModelIndex
&
rhs
)
返回
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.