QItemSelection Class
QItemSelection 클래스는 모델에서 선택된 항목에 대한 정보를 관리합니다. 더 보기...
| 헤더: | #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 클래스는 모델/뷰(Model/View) 클래스 중 하나이며, Qt의 모델/뷰 프레임워크의 일부입니다.
항목 선택은 기존 모델의 항목 범위를 포함하도록 생성 및 초기화될 수 있습니다. 다음 예제는 주어진 model 에서 topLeft 로 시작하여 bottomRight 로 끝나는 항목 범위를 포함하는 선택 항목을 생성합니다.
QItemSelection *selection = new QItemSelection(topLeft, bottomRight);빈 항목 선택 객체를 생성한 후, 필요에 따라 나중에 항목을 채울 수 있습니다. 따라서 항목 선택 객체를 생성할 때 모델을 사용할 수 없는 경우, 위 코드를 다음과 같이 재작성할 수 있습니다:
QItemSelection *selection = new QItemSelection();
//...
selection->select(topLeft, bottomRight);QItemSelection은 선택 항목의 각 항목에 대한 모델 항목 인덱스를 기록하는 대신 선택 범위를 사용하여 메모리를 절약하고 불필요한 작업을 방지합니다. 일반적으로 이 클래스의 인스턴스는 서로 겹치지 않는 선택 범위 목록을 포함합니다.
merge()를 사용하면 중복되는 범위 없이 한 항목 선택 집합을 다른 항목 선택 집합에 병합할 수 있습니다. split()를 사용하면 다른 선택 범위를 기준으로 하나의 선택 범위를 더 작은 범위들로 분할할 수 있습니다.
‘모델/뷰 프로그래밍 ’ 및 ‘ QItemSelectionModel ’항목도 참조하십시오 .
멤버 함수 문서
[implicit] 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 로 지정된 오른쪽 하단 항목까지의 범위 내에 있는 항목들을 목록에 추가합니다.
참고: topLeft 와 bottomRight 은 동일한 부모를 가져야 합니다.
[static] void QItemSelection::split(const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)
선택 영역 range 을 선택 영역 other 범위 기준으로 분할합니다. other 에 포함된 모든 항목을 range 에서 제거하고, 그 결과를 result 에 저장합니다. 이는 집합의 뺄셈 연산의 의미와 비교할 수 있습니다.
merge()도 참조하십시오 .
© 2026 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.