Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QPersistentModelIndex Class Reference

\inmodule QtCore More...

#include <qabstractitemmodel.h>

+ Collaboration diagram for QPersistentModelIndex:

Public Member Functions

 QPersistentModelIndex ()
 
 QPersistentModelIndex (const QModelIndex &index)
 Creates a new QPersistentModelIndex that is a copy of the model index.
 
 QPersistentModelIndex (const QPersistentModelIndex &other)
 Creates a new QPersistentModelIndex that is a copy of the other persistent model index.
 
 ~QPersistentModelIndex ()
 
QPersistentModelIndexoperator= (const QPersistentModelIndex &other)
 Sets the persistent model index to refer to the same item in a model as the other persistent model index.
 
 QPersistentModelIndex (QPersistentModelIndex &&other) noexcept
 Move-constructs a QPersistentModelIndex instance, making it point at the same object that other was pointing to.
 
void swap (QPersistentModelIndex &other) noexcept
 
QPersistentModelIndexoperator= (const QModelIndex &other)
 Sets the persistent model index to refer to the same item in a model as the other model index.
 
 operator QModelIndex () const
 Cast operator that returns a QModelIndex.
 
int row () const
 Returns the row this persistent model index refers to.
 
int column () const
 Returns the column this persistent model index refers to.
 
voidinternalPointer () const
 
const voidconstInternalPointer () const
 
quintptr internalId () const
 
QModelIndex parent () const
 Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no parent.
 
QModelIndex sibling (int row, int column) const
 Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this position.
 
QVariant data (int role=Qt::DisplayRole) const
 Returns the data for the given role for the item referred to by the index, or a default-constructed QVariant if this persistent model index is \l{isValid()}{invalid}.
 
void multiData (QModelRoleDataSpan roleDataSpan) const
 Populates the given roleDataSpan for the item referred to by the index.
 
Qt::ItemFlags flags () const
 
const QAbstractItemModelmodel () const
 Returns the model that the index belongs to.
 
bool isValid () const
 Returns {true} if this persistent model index is valid; otherwise returns {false}.
 

Friends

size_t qHash (const QPersistentModelIndex &index, size_t seed=0)
 
bool qHashEquals (const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept
 
Q_CORE_EXPORT bool comparesEqual (const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)
 
Q_CORE_EXPORT bool comparesEqual (const QPersistentModelIndex &lhs, const QModelIndex &rhs)
 
Q_CORE_EXPORT Qt::strong_ordering compareThreeWay (const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)
 
Q_CORE_EXPORT Qt::strong_ordering compareThreeWay (const QPersistentModelIndex &lhs, const QModelIndex &rhs)
 
Q_CORE_EXPORT QDebug operator<< (QDebug dbg, const QPersistentModelIndex &idx)
 

Detailed Description

\inmodule QtCore

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

\compares strong \compareswith strong QModelIndex \endcompareswith

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.

Note
You cannot store a QStandardItemModel's QPersistentModelIndex in one of the model's items.
See also
{Model/View Programming}, QModelIndex, QAbstractItemModel

Definition at line 183 of file qabstractitemmodel.h.

Constructor & Destructor Documentation

◆ QPersistentModelIndex() [1/4]

QPersistentModelIndex::QPersistentModelIndex ( )

Definition at line 336 of file qabstractitemmodel.cpp.

◆ QPersistentModelIndex() [2/4]

QPersistentModelIndex::QPersistentModelIndex ( const QModelIndex & index)

Creates a new QPersistentModelIndex that is a copy of the model index.

Definition at line 358 of file qabstractitemmodel.cpp.

◆ QPersistentModelIndex() [3/4]

QPersistentModelIndex::QPersistentModelIndex ( const QPersistentModelIndex & other)

Creates a new QPersistentModelIndex that is a copy of the other persistent model index.

Definition at line 348 of file qabstractitemmodel.cpp.

◆ ~QPersistentModelIndex()

QPersistentModelIndex::~QPersistentModelIndex ( )

Definition at line 373 of file qabstractitemmodel.cpp.

◆ QPersistentModelIndex() [4/4]

QPersistentModelIndex::QPersistentModelIndex ( QPersistentModelIndex && other)
inlinenoexcept

Move-constructs a QPersistentModelIndex instance, making it point at the same object that other was pointing to.

Since
5.2

Definition at line 197 of file qabstractitemmodel.h.

Member Function Documentation

◆ column()

int QPersistentModelIndex::column ( ) const

Returns the column this persistent model index refers to.

Definition at line 524 of file qabstractitemmodel.cpp.

Referenced by testing.tools.encode_pdf_filter._Ascii85DecodePdfStream::close().

+ Here is the caller graph for this function:

◆ constInternalPointer()

const void * QPersistentModelIndex::constInternalPointer ( ) const
Since
6.0

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

Definition at line 556 of file qabstractitemmodel.cpp.

◆ data()

QVariant QPersistentModelIndex::data ( int role = Qt::DisplayRole) const

Returns the data for the given role for the item referred to by the index, or a default-constructed QVariant if this persistent model index is \l{isValid()}{invalid}.

See also
Qt::ItemDataRole, QAbstractItemModel::setData()

Definition at line 613 of file qabstractitemmodel.cpp.

◆ flags()

Qt::ItemFlags QPersistentModelIndex::flags ( ) const
Since
4.2

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

Definition at line 639 of file qabstractitemmodel.cpp.

◆ internalId()

quintptr QPersistentModelIndex::internalId ( ) const

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

Definition at line 572 of file qabstractitemmodel.cpp.

◆ internalPointer()

void * QPersistentModelIndex::internalPointer ( ) const

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

Definition at line 540 of file qabstractitemmodel.cpp.

◆ isValid()

bool QPersistentModelIndex::isValid ( ) const

Returns {true} if this persistent 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(), column()

Definition at line 668 of file qabstractitemmodel.cpp.

◆ model()

const QAbstractItemModel * QPersistentModelIndex::model ( ) const

Returns the model that the index belongs to.

Definition at line 649 of file qabstractitemmodel.cpp.

◆ multiData()

void QPersistentModelIndex::multiData ( QModelRoleDataSpan roleDataSpan) const

Populates the given roleDataSpan for the item referred to by the index.

Since
6.0
See also
Qt::ItemDataRole, QAbstractItemModel::setData()

Definition at line 628 of file qabstractitemmodel.cpp.

◆ operator QModelIndex()

QPersistentModelIndex::operator QModelIndex ( ) const

Cast operator that returns a QModelIndex.

Definition at line 475 of file qabstractitemmodel.cpp.

◆ operator=() [1/2]

QPersistentModelIndex & QPersistentModelIndex::operator= ( const QModelIndex & other)

Sets the persistent model index to refer to the same item in a model as the other model index.

Definition at line 456 of file qabstractitemmodel.cpp.

◆ operator=() [2/2]

QPersistentModelIndex & QPersistentModelIndex::operator= ( const QPersistentModelIndex & other)

Sets the persistent model index to refer to the same item in a model as the other persistent model index.

Definition at line 435 of file qabstractitemmodel.cpp.

◆ parent()

QModelIndex QPersistentModelIndex::parent ( ) const

Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no parent.

See also
sibling(), model()

Definition at line 585 of file qabstractitemmodel.cpp.

◆ row()

int QPersistentModelIndex::row ( ) const

Returns the row this persistent model index refers to.

Definition at line 511 of file qabstractitemmodel.cpp.

◆ sibling()

QModelIndex QPersistentModelIndex::sibling ( int row,
int column ) const

Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this position.

See also
parent()

Definition at line 599 of file qabstractitemmodel.cpp.

◆ swap()

void QPersistentModelIndex::swap ( QPersistentModelIndex & other)
inlinenoexcept
Since
5.0 \memberswap{persistent modelindex}

Definition at line 200 of file qabstractitemmodel.h.

Friends And Related Symbol Documentation

◆ comparesEqual [1/2]

Q_CORE_EXPORT bool comparesEqual ( const QPersistentModelIndex & lhs,
const QModelIndex & rhs )
friend

Definition at line 498 of file qabstractitemmodel.cpp.

◆ comparesEqual [2/2]

Q_CORE_EXPORT bool comparesEqual ( const QPersistentModelIndex & lhs,
const QPersistentModelIndex & rhs )
friend

Definition at line 397 of file qabstractitemmodel.cpp.

◆ compareThreeWay [1/2]

Q_CORE_EXPORT Qt::strong_ordering compareThreeWay ( const QPersistentModelIndex & lhs,
const QModelIndex & rhs )
friend

Definition at line 424 of file qabstractitemmodel.cpp.

◆ compareThreeWay [2/2]

Q_CORE_EXPORT Qt::strong_ordering compareThreeWay ( const QPersistentModelIndex & lhs,
const QPersistentModelIndex & rhs )
friend

Definition at line 414 of file qabstractitemmodel.cpp.

◆ operator<<

Q_CORE_EXPORT QDebug operator<< ( QDebug dbg,
const QPersistentModelIndex & idx )
friend

Definition at line 682 of file qabstractitemmodel.cpp.

◆ qHash

size_t qHash ( const QPersistentModelIndex & index,
size_t seed = 0 )
friend
Since
5.0

Returns a hash of the QPersistentModelIndex index, using seed to seed the calculation.

Definition at line 242 of file qabstractitemmodel.h.

◆ qHashEquals

bool qHashEquals ( const QPersistentModelIndex & a,
const QPersistentModelIndex & b )
friend

Definition at line 222 of file qabstractitemmodel.h.


The documentation for this class was generated from the following files: