QItemSelection Class

QItemSelection 클래스는 모델에서 선택한 항목에 대한 정보를 관리합니다. 더 보기...

Header: #include <QItemSelection>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
상속합니다: QList

공용 함수

QItemSelection()
QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight)
bool contains(const QModelIndex &index) const
QModelIndexList indexes() const
void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)
void select(const QModelIndex &topLeft, const QModelIndex &bottomRight)

정적 공용 멤버

void split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)

상세 설명

QItemSelection은 사용자가 선택한 모델의 항목을 설명합니다. QItemSelection은 기본적으로 선택 범위의 목록입니다( QItemSelectionRange 참조). 선택 범위를 생성 및 조작하고 모델에서 항목의 범위를 선택하는 함수를 제공합니다.

QItemSelection 클래스는 모델/뷰 클래스 중 하나이며 Qt의 모델/뷰 프레임워크의 일부입니다.

항목 선택은 기존 모델의 항목 범위를 포함하도록 구성하고 초기화할 수 있습니다. 다음 예제는 topLeft 에서 시작하여 bottomRight 에서 끝나는 주어진 model 의 범위의 항목을 포함하는 선택 항목을 구성합니다.

QItemSelection *selection = new QItemSelection(topLeft, bottomRight);

빈 항목 선택을 구성한 다음 필요에 따라 나중에 채울 수 있습니다. 따라서 항목 선택을 구성할 때 모델을 사용할 수 없는 경우 위의 코드를 다음과 같이 다시 작성할 수 있습니다:

QItemSelection *selection = new QItemSelection();
...
selection->select(topLeft, bottomRight);

QItemSelection은 선택 항목의 각 항목에 대한 모델 항목 인덱스를 기록하는 대신 선택 범위로 작업하여 메모리를 절약하고 불필요한 작업을 피합니다. 일반적으로 이 클래스의 인스턴스에는 겹치지 않는 선택 범위의 목록이 포함됩니다.

merge()를 사용하여 한 항목 선택 범위를 겹치지 않게 다른 항목 선택 범위로 병합합니다. split ()를 사용하여 한 선택 범위를 다른 선택 범위를 기준으로 더 작은 범위로 분할합니다.

모델/보기 프로그래밍QItemSelectionModel참조하십시오 .

멤버 함수 문서

[noexcept default] QItemSelection::QItemSelection()

빈 선택 영역을 구성합니다.

QItemSelection::QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight)

topLeft 인덱스로 지정된 왼쪽 상단 모델 항목에서 bottomRight 으로 지정된 오른쪽 하단 항목까지 확장되는 항목 선택을 구성합니다.

bool QItemSelection::contains(const QModelIndex &index) const

선택 항목에 지정된 index 이 포함되어 있으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

QModelIndexList QItemSelection::indexes() const

선택한 항목에 해당하는 모델 인덱스 목록을 반환합니다.

void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)

주어진 command 을 사용하여 other 선택 항목을 이 QItemSelection 과 병합합니다. 이 방법은 범위가 겹치지 않도록 보장합니다.

QItemSelectionModel::Select, QItemSelectionModel::Deselect, QItemSelectionModel::Toggle 만 지원됩니다.

split()도 참조하세요 .

void QItemSelection::select(const QModelIndex &topLeft, const QModelIndex &bottomRight)

topLeft 인덱스로 지정된 왼쪽 상단 모델 항목에서 bottomRight 으로 지정된 오른쪽 하단 항목까지 확장되는 범위의 항목을 목록에 추가합니다.

참고: topLeftbottomRight 은 같은 부모를 가져야 합니다.

[static] void QItemSelection::split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)

other 범위를 사용하여 range 선택 영역을 분할합니다. range 에서 other 의 모든 항목을 제거하고 결과를 result 에 넣습니다. 이는 집합의 빼기 연산의 의미와 비교할 수 있습니다.

merge()도 참조하세요 .

© 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.