QPersistentModelIndex Class

QPersistentModelIndex 클래스는 데이터 모델에서 데이터를 찾는 데 사용됩니다. 더 보기...

Header: #include <QPersistentModelIndex>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

이 클래스는 매우 유사합니다.

이 클래스는 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
(since 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)

상세 설명

QPersistentModelIndex는 응용 프로그램에서 저장할 수 있고 나중에 모델의 정보에 액세스하는 데 사용할 수 있는 모델 인덱스입니다. QModelIndex 클래스와 달리 QPersistentModelIndex는 모델에서 액세스할 수 있는 한 항목에 대한 참조가 계속 유효하도록 보장하므로 저장하는 것이 안전합니다.

영구 모델 인덱스를 사용하기 전에 인덱스가 유효한지 확인하는 것이 좋습니다.

참고: 모델의 항목 중 하나에 QStandardItemModel 의 QPersistentModelIndex 를 저장할 수 없습니다.

모델/뷰 프로그래밍, QModelIndexQAbstractItemModel참조하세요 .

멤버 함수 문서

QPersistentModelIndex::QPersistentModelIndex(const QModelIndex &index)

모델의 복사본인 새 QPersistentModelIndex를 생성합니다 index.

QPersistentModelIndex::QPersistentModelIndex(const QPersistentModelIndex &other)

other 영구 모델 인덱스의 복사본인 새 QPersistentModelIndex를 생성합니다.

[noexcept] QPersistentModelIndex::QPersistentModelIndex(QPersistentModelIndex &&other)

Move는 QPersistentModelIndex 인스턴스를 생성하여 other 이 가리키던 것과 동일한 객체를 가리키도록 합니다.

int QPersistentModelIndex::column() const

이 영구 모델 인덱스가 참조하는 열을 반환합니다.

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

인덱스가 참조하는 항목에 대해 지정된 role 또는 이 영구 모델 인덱스가 invalid 인 경우 기본으로 구성된 QVariant 의 데이터를 반환합니다.

Qt::ItemDataRoleQAbstractItemModel::setData()도 참조하세요 .

Qt::ItemFlags QPersistentModelIndex::flags() const

인덱스가 참조하는 항목의 플래그를 반환합니다.

bool QPersistentModelIndex::isValid() const

이 영구 모델 인덱스가 유효하면 true 를 반환하고, 그렇지 않으면 false 을 반환합니다.

유효한 인덱스는 모델에 속하며 음수가 아닌 행과 열 번호를 갖습니다.

model(), row() 및 column()도 참조하세요 .

const QAbstractItemModel *QPersistentModelIndex::model() const

인덱스가 속한 모델을 반환합니다.

[since 6.0] void QPersistentModelIndex::multiData(QModelRoleDataSpan roleDataSpan) const

인덱스가 참조하는 항목에 대해 주어진 roleDataSpan 을 채웁니다.

이 함수는 Qt 6.0에 도입되었습니다.

Qt::ItemDataRoleQAbstractItemModel::setData()도 참조하세요 .

QModelIndex QPersistentModelIndex::parent() const

이 영구 인덱스의 부모 QModelIndex 또는 부모가 없는 경우 유효하지 않은 QModelIndex 을 반환합니다.

sibling() 및 model()도 참조하세요 .

int QPersistentModelIndex::row() const

이 영구 모델 인덱스가 참조하는 행을 반환합니다.

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

이 위치에 형제자매가 없는 경우 rowcolumn 또는 잘못된 QModelIndex 을 반환합니다.

parent()도 참조하세요 .

[noexcept] void QPersistentModelIndex::swap(QPersistentModelIndex &other)

이 영구 모델 인덱스를 other 로 바꿉니다. 이 작업은 매우 빠르며 실패하지 않습니다.

QModelIndex QPersistentModelIndex::operator QModelIndex() const

를 반환하는 캐스트 연산자 QModelIndex.

[noexcept] QPersistentModelIndex &QPersistentModelIndex::operator=(QPersistentModelIndex &&other)

이동-이 other 인스턴스를 QPersistentModelIndex 인스턴스에 할당합니다.

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

영구 모델 인덱스가 모델에서 other 모델 인덱스와 동일한 항목을 참조하도록 설정합니다.

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

모델에서 other 영구 모델 인덱스와 동일한 항목을 참조하도록 영구 모델 인덱스를 설정합니다.

관련 비회원

[noexcept] size_t qHash(const QPersistentModelIndex &key, size_t seed = 0)

seed 을 사용하여 key 에 대한 해시값을 반환합니다.

[noexcept] bool operator!=(const QPersistentModelIndex &lhs, const QModelIndex &rhs)

lhs 영구 모델 인덱스가 rhs 모델 인덱스와 동일한 위치를 참조하지 않으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

[noexcept] bool operator!=(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

lhs 영구 모델 인덱스가 rhs 영구 모델 인덱스와 같지 않으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

[noexcept] bool operator<(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

lhs 영구 모델 인덱스가 rhs 영구 모델 인덱스보다 작으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

영구 모델 인덱스의 내부 데이터 포인터, 행, 열 및 모델 값은 다른 영구 모델 인덱스와 비교할 때 사용됩니다.

[noexcept] bool operator==(const QPersistentModelIndex &lhs, const QModelIndex &rhs)

lhs 영구 모델 인덱스가 rhs 모델 인덱스와 같은 위치를 참조하는 경우 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

영구 모델 인덱스의 내부 데이터 포인터, 행, 열 및 모델 값은 다른 모델 인덱스와 비교할 때 사용됩니다.

[noexcept] bool operator==(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs)

lhs 영구 모델 인덱스가 rhs 영구 모델 인덱스와 같으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

영구 모델 인덱스의 내부 데이터 포인터, 행, 열 및 모델 값은 다른 영구 모델 인덱스와 비교할 때 사용됩니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.