QItemSelectionModel Class
QItemSelectionModel 클래스는 뷰에서 선택한 항목을 추적합니다. 더 보기...
Header: | #include <QItemSelectionModel> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
상속합니다: | QObject |
공용 유형
enum | SelectionFlag { NoUpdate, Clear, Select, Deselect, Toggle, …, ClearAndSelect } |
flags | SelectionFlags |
속성
- selectedIndexes : const QModelIndexList
공용 기능
QItemSelectionModel(QAbstractItemModel *model = nullptr) | |
QItemSelectionModel(QAbstractItemModel *model, QObject *parent) | |
virtual | ~QItemSelectionModel() |
bool | columnIntersectsSelection(int column, const QModelIndex &parent = QModelIndex()) const |
QModelIndex | currentIndex() const |
bool | hasSelection() const |
bool | isColumnSelected(int column, const QModelIndex &parent = QModelIndex()) const |
bool | isRowSelected(int row, const QModelIndex &parent = QModelIndex()) const |
bool | isSelected(const QModelIndex &index) const |
QAbstractItemModel * | model() |
const QAbstractItemModel * | model() const |
bool | rowIntersectsSelection(int row, const QModelIndex &parent = QModelIndex()) const |
QModelIndexList | selectedColumns(int row = 0) const |
QModelIndexList | selectedIndexes() const |
QModelIndexList | selectedRows(int column = 0) const |
const QItemSelection | selection() const |
void | setModel(QAbstractItemModel *model) |
공용 슬롯
virtual void | clear() |
virtual void | clearCurrentIndex() |
void | clearSelection() |
virtual void | reset() |
virtual void | select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) |
virtual void | select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) |
virtual void | setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) |
신호
void | currentChanged(const QModelIndex ¤t, const QModelIndex &previous) |
void | currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous) |
void | currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) |
void | modelChanged(QAbstractItemModel *model) |
void | selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
보호된 기능
void | emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection) |
상세 설명
QItemSelectionModel은 한 뷰 또는 여러 뷰에서 동일한 모델에 선택된 항목을 추적합니다. 또한 뷰에서 현재 선택된 항목도 추적합니다.
QItemSelectionModel 클래스는 모델/뷰 클래스 중 하나이며 Qt의 모델/뷰 프레임워크의 일부입니다.
선택된 항목은 범위를 사용하여 저장됩니다. 선택한 항목을 수정하려면 select()를 사용하고 QItemSelection 또는 QModelIndex 와 QItemSelectionModel::SelectionFlag 를 제공합니다.
QItemSelectionModel은 커밋된 선택 항목과 현재 선택의 일부인 항목을 모두 처리하는 선택 관리에 대한 2계층 접근 방식을 취합니다. 현재 선택된 항목은 현재 대화형 선택의 일부입니다(예: 고무줄 선택 또는 키보드 시프트 선택).
현재 선택된 항목을 업데이트하려면 QItemSelectionModel::Current 및 기타 SelectionFlags 중 하나의 비트 OR을 사용합니다. QItemSelectionModel::Current 명령을 생략하면 현재 선택 항목이 새로 만들어지고 이전 선택 항목이 전체 선택 항목에 추가됩니다. 모든 함수는 두 레이어에서 모두 작동합니다. 예를 들어 selecteditems()는 두 레이어의 항목을 모두 반환합니다.
참고: 5.5부터 model, hasSelection, currentIndex 은 메타 객체 속성입니다.
모델/보기 프로그래밍 및 QAbstractItemModel 를참조하세요 .
멤버 유형 문서
열거형 QItemSelectionModel::SelectionFlag
플래그 QItemSelectionModel::SelectionFlags
선택 모델이 업데이트되는 방식을 설명하는 열거형입니다.
Constant | 값 | 설명 |
---|---|---|
QItemSelectionModel::NoUpdate | 0x0000 | 선택이 수행되지 않습니다. |
QItemSelectionModel::Clear | 0x0001 | 전체 선택이 지워집니다. |
QItemSelectionModel::Select | 0x0002 | 지정된 모든 인덱스가 선택됩니다. |
QItemSelectionModel::Deselect | 0x0004 | 지정된 모든 인덱스가 선택 해제됩니다. |
QItemSelectionModel::Toggle | 0x0008 | 지정된 모든 인덱스가 현재 상태에 따라 선택되거나 선택 해제됩니다. |
QItemSelectionModel::Current | 0x0010 | 현재 선택 항목이 업데이트됩니다. |
QItemSelectionModel::Rows | 0x0020 | 모든 인덱스가 스팬 행으로 확장됩니다. |
QItemSelectionModel::Columns | 0x0040 | 모든 인덱스가 스팬 열로 확장됩니다. |
QItemSelectionModel::SelectCurrent | Select | Current | 편의를 위해 선택과 현재를 조합하여 제공합니다. |
QItemSelectionModel::ToggleCurrent | Toggle | Current | 편의를 위해 제공되는 토글과 현재의 조합입니다. |
QItemSelectionModel::ClearAndSelect | Clear | Select | 편의를 위해 제공되는 Clear와 Select의 조합입니다. |
SelectionFlags 유형은 QFlags<선택 플래그>에 대한 타입 정의입니다. SelectionFlag 값의 OR 조합을 저장합니다.
속성 문서
[read-only]
selectedIndexes : const QModelIndexList
액세스 기능:
QModelIndexList | selectedIndexes() const |
알림 신호:
void | selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
멤버 함수 문서
[explicit]
QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model = nullptr)
지정된 항목에 대해 작동하는 선택 모델을 구축합니다 model.
[explicit]
QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent)
parent 을 사용하여 지정된 항목 model 에 대해 작동하는 선택 모델을 구축합니다.
[virtual noexcept]
QItemSelectionModel::~QItemSelectionModel()
선택 모델을 삭제합니다.
[virtual slot]
void QItemSelectionModel::clear()
선택 모델을 지웁니다. selectionChanged () 및 currentChanged()를 방출합니다.
[virtual slot]
void QItemSelectionModel::clearCurrentIndex()
현재 인덱스를 지웁니다. currentChanged ()를 반환합니다.
[slot]
void QItemSelectionModel::clearSelection()
선택 모델에서 선택을 지웁니다. selectionChanged ()를 전송합니다.
[invokable]
bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelIndex &parent = QModelIndex()) const
주어진 parent 으로 column 에 선택된 항목이 있으면 true
을 반환합니다.
참고: Qt 5.15부터 parent 의 기본 인수는 빈 모델 인덱스입니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하십시오.
[signal]
void QItemSelectionModel::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
이 신호는 현재 항목이 변경될 때마다 발생합니다. previous 모델 항목 인덱스는 선택 항목의 현재 항목으로 current 인덱스로 대체됩니다.
항목 모델이 재설정되면 이 신호가 발생하지 않습니다.
currentIndex(), setCurrentIndex() 및 selectionChanged()도 참조하세요 .
[signal]
void QItemSelectionModel::currentColumnChanged(const QModelIndex ¤t, const QModelIndex &previous)
이 신호는 current 항목이 변경되고 해당 열이 previous 현재 항목의 열과 다른 경우 발생합니다.
항목 모델이 재설정된 경우에는 이 신호가 발생하지 않습니다.
currentChanged(), currentRowChanged(), currentIndex() 및 setCurrentIndex()도 참조하세요 .
QModelIndex QItemSelectionModel::currentIndex() const
현재 항목의 모델 항목 인덱스를 반환하거나 현재 항목이 없는 경우 잘못된 인덱스를 반환합니다.
setCurrentIndex()도 참조하세요 .
[signal]
void QItemSelectionModel::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
이 신호는 current 항목이 변경되고 해당 행이 previous 현재 항목의 행과 다른 경우 발생합니다.
항목 모델이 재설정된 경우에는 이 신호가 발생하지 않습니다.
currentChanged(), currentColumnChanged(), currentIndex() 및 setCurrentIndex()도 참조하세요 .
[protected]
void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection)
newSelection 및 oldSelection 두 선택 항목을 비교하고 선택 해제된 항목과 선택된 항목을 비교하여 selectionChanged()를 출력합니다.
bool QItemSelectionModel::hasSelection() const
선택 모델에 선택된 항목이 포함되어 있으면 true
을 반환하고, 그렇지 않으면 false
을 반환합니다.
[invokable]
bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent = QModelIndex()) const
주어진 parent 으로 column 에서 모든 항목이 선택된 경우 true
을 반환합니다.
이 함수는 일반적으로 같은 열의 모든 항목에 대해 isSelected()를 호출하는 것보다 빠르며 선택되지 않은 항목은 무시됩니다.
참고: Qt 5.15부터 parent 의 기본 인수는 빈 모델 인덱스입니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.
[invokable]
bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent = QModelIndex()) const
주어진 parent 으로 row 에서 모든 항목이 선택된 경우 true
을 반환합니다.
이 함수는 일반적으로 같은 행의 모든 항목에 대해 isSelected()를 호출하는 것보다 빠르며 선택되지 않은 항목은 무시됩니다.
참고: Qt 5.15부터 parent 의 기본 인수는 빈 모델 인덱스입니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.
[invokable]
bool QItemSelectionModel::isSelected(const QModelIndex &index) const
지정된 모델 항목 index 이 선택된 경우 true
을 반환합니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.
QAbstractItemModel *QItemSelectionModel::model()
선택 모델에 의해 작동되는 항목 모델을 반환합니다.
setModel()도 참조하세요 .
const QAbstractItemModel *QItemSelectionModel::model() const
선택 모델에 의해 작동되는 항목 모델을 반환합니다.
[signal]
void QItemSelectionModel::modelChanged(QAbstractItemModel *model)
이 신호는 setModel()로 model 을 성공적으로 설정하면 전송됩니다.
[virtual slot]
void QItemSelectionModel::reset()
선택 모델을 지웁니다. 신호를 방출하지 않습니다.
[invokable]
bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &parent = QModelIndex()) const
주어진 parent 으로 row 에 선택된 항목이 있는 경우 true
를 반환합니다.
참고: Qt 5.15부터 parent 의 기본 인수는 빈 모델 인덱스입니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하십시오.
[virtual slot]
void QItemSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
지정된 command 을 사용하여 selection 항목을 선택하고 selectionChanged()를 전송합니다.
QItemSelectionModel::SelectionFlag도 참조하세요 .
[virtual slot]
void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
지정된 command 을 사용하여 모델 항목 index 을 선택하고 selectionChanged()을 내보냅니다.
QItemSelectionModel::SelectionFlags도 참조하세요 .
[invokable]
QModelIndexList QItemSelectionModel::selectedColumns(int row = 0) const
모든 행이 선택된 열에 대해 주어진 row 의 인덱스를 반환합니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.
selectedIndexes() 및 selectedRows()도 참조하세요 .
QModelIndexList QItemSelectionModel::selectedIndexes() const
선택한 모든 모델 항목 인덱스의 목록을 반환합니다. 이 목록에는 중복 항목이 포함되지 않으며 정렬되지 않습니다.
참고: 선택한 인덱스 속성에 대한 게터 함수입니다.
[invokable]
QModelIndexList QItemSelectionModel::selectedRows(int column = 0) const
모든 열이 선택된 행에 대해 주어진 column 의 인덱스를 반환합니다.
참고: 이 함수는 메타 객체 시스템과 QML을 통해 호출할 수 있습니다. Q_INVOKABLE 을 참조하세요.
selectedIndexes() 및 selectedColumns()도 참조하세요 .
const QItemSelection QItemSelectionModel::selection() const
선택 모델에 저장된 선택 범위를 반환합니다.
[signal]
void QItemSelectionModel::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
이 신호는 선택 항목이 변경될 때마다 발산됩니다. 선택 영역의 변경은 deselected 항목의 항목 선택과 selected 항목의 항목 선택으로 표시됩니다.
현재 인덱스는 선택 항목과 독립적으로 변경된다는 점에 유의하세요. 또한 이 신호는 항목 모델이 재설정될 때는 발생하지 않습니다.
선택된 상태로 유지되지만 인덱스가 변경되는 항목은 selected 및 deselected 에 포함되지 않습니다. 따라서 선택한 항목의 인덱스만 변경되는 경우 selected 및 deselected 이 모두 비어 있는 상태에서 이 신호가 전송될 수 있습니다.
참고: 속성에 대한 알림 신호 selectedIndexes.
select() 및 currentChanged()도 참조하세요 .
[virtual slot]
void QItemSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
모델 항목 index 을 현재 항목으로 설정하고 currentChanged()을 출력합니다. 현재 항목은 키보드 탐색 및 초점 표시에 사용되며, 선택한 항목과 독립적이지만 선택한 항목도 현재 항목이 될 수 있습니다.
지정된 command 에 따라 index 도 현재 선택 항목의 일부가 될 수 있습니다.
currentIndex() 및 select()도 참조하세요 .
void QItemSelectionModel::setModel(QAbstractItemModel *model)
모델을 model 로 설정합니다. modelChanged() 신호가 전송됩니다.
model() 및 modelChanged()도 참조하세요 .
© 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.