VerticalHeaderView QML Type
TableView 와 함께 사용할 수 있는 세로 방향 헤더 보기를 제공합니다. 더 보기...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
속성
- model : QVariant
- movableRows : bool
(since 6.8) - syncView : TableView
- textRole : string
상세 설명
VerticalHeaderView는 스타일이 적용된 테이블 헤더를 제공합니다. 이 뷰는 독립적인 뷰로 사용하거나 TableView 의 헤더로 사용할 수 있습니다.
TableView 를 VerticalHeaderView의 syncView 속성에 할당하면 TableView 에 헤더를 추가할 수 있습니다. 그러면 플릭킹 시 헤더와 테이블이 동기화되어 표시됩니다.
기본적으로 VerticalHeaderView는 sync view's 의 model 에서 가져온 header data 을 표시합니다. 해당 모델의 헤더 데이터를 사용하지 않으려는 경우, 또는 syncView 을 사용하지 않는 경우, model 속성에 모델을 명시적으로 할당할 수 있습니다.
참고: QAbstractItemModel 의 헤더 데이터를 표시하기위해 , VerticalHeaderView는 내부적으로 모델의 헤더 데이터를 독립적인 프록시 모델로 감쌉니다. 이 모델은 application model 과 모델 항목을 전혀 공유하지 않습니다. 즉, index()과 같은 함수를 호출할 경우, 반환되는 모델 인덱스는 애플리케이션 모델이 아닌 프록시 모델에 속하게 됩니다.
기본적으로 ` textRole `는 ` "display"`로 설정되어 있어, 모델의 ` Qt::DisplayRole `에 있는 데이터가 사용됩니다. 대신 다른 데이터가 표시되도록 하려면 이 값을 다른 역할 이름으로 설정할 수 있습니다.
애플리케이션은 헤더를 씬 내의 올바른 위치에 배치하는 역할을 담당합니다. 단일 TableView 에 원하는 만큼 헤더를 추가할 수 있으며, 이는 예를 들어 테이블의 네 면 모두에 헤더를 배치하려는 경우 유용할 수 있습니다.
다음 코드 조각은 테이블 뷰에 가로 및 세로 헤더 뷰를 추가하는 방법을 보여줍니다:
import QtQuick
import QtQuick.Controls
import Qt.labs.qmlmodels
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("HeaderView")
Rectangle {
anchors.fill: parent
// The background color will show through the cell
// spacing, and therefore become the grid line color.
color: Application.styleHints.appearance === Qt.Light ? palette.mid : palette.midlight
HorizontalHeaderView {
id: horizontalHeader
anchors.left: tableView.left
anchors.top: parent.top
syncView: tableView
clip: true
}
VerticalHeaderView {
id: verticalHeader
anchors.top: tableView.top
anchors.left: parent.left
syncView: tableView
clip: true
}
TableView {
id: tableView
anchors.left: verticalHeader.right
anchors.top: horizontalHeader.bottom
anchors.right: parent.right
anchors.bottom: parent.bottom
clip: true
columnSpacing: 1
rowSpacing: 1
model: TableModel {
TableModelColumn { display: "name" }
TableModelColumn { display: "color" }
rows: [
{
"name": "cat",
"color": "black"
},
{
"name": "dog",
"color": "brown"
},
{
"name": "bird",
"color": "white"
}
]
}
delegate: Rectangle {
implicitWidth: 100
implicitHeight: 20
color: palette.base
Label {
text: display
}
}
}
}
}VerticalHeaderView의 경우 기본적으로 resizableColumns 가 true 로 설정되어 있습니다.
HorizontalHeaderView도 참조하십시오 .
속성 설명서
model : QVariant
이 속성은 세로형 헤더 뷰에 데이터를 제공하는 모델을 포함합니다.
기본적으로 수직 헤더 뷰는 sync view's model 에서 제공하는 header data 를 표시합니다. 해당 모델의 헤더 데이터를 사용하지 않으려는 경우, 또는 syncView 를 사용하지 않는 경우, 이 속성에 모델을 명시적으로 할당할 수 있습니다. model 가 QAbstractTableModel 인 경우, header data 가 사용됩니다. 그렇지 않고 QAbstractItemModel 인 경우, data 가 사용됩니다.
QAbstractItemModels 외에도 JavaScript 배열과 같은 다른 종류의 모델을 이 속성에 할당할 수 있습니다.
TableView, model 및 QAbstractTableModel도 참조하십시오 .
movableRows : bool [since 6.8]
이 속성을 사용하면 사용자가 뷰에서 행을 이동할 수 있습니다. 기본값은 false 입니다.
참고: 이 속성이 설정된경우 , ` VerticalHeaderView `을 통해 사용자가 행을 원하는 위치로 드래그 앤 드롭할 수 있습니다. ` syncView `이 활성화되면, 모든 변경 사항이 해당 뷰 항목에 적용됩니다.
이 속성은 Qt 6.8에서 도입되었습니다.
syncView : TableView
이 속성은 동기화할 TableView 를 저장합니다.
이 속성이 다른 ` TableView`에 바인딩되면, 헤더와 테이블 모두 열 너비, 열 간격 및 수직 스크롤에 대해 동기화됩니다.
model 가 명시적으로 설정되지 않은 경우, 헤더는 syncView의 모델을 사용하여 열에 레이블을 지정합니다.
textRole : string
이 속성은 각 헤더 셀에 텍스트를 표시하는 데 사용되는 모델 역할을 저장합니다.
모델에 여러 역할이 있는 경우, textRole을 설정하여 표시할 역할을 지정할 수 있습니다.
모델의 데이터를 표시할 때 할당된 'textRole' textRole 을 준수하는 것은 델리게이트의 책임입니다. ` HorizontalHeaderViewDelegate ` 및 ` VerticalHeaderViewDelegate `는 이를 자동으로 처리하지만, 사용자 정의 델리게이트는 이 동작을 명시적으로 구현해야 합니다.
model이 QAbstractItemModel 인 경우 기본값은 "display"이며, 그렇지 않은 경우 빈 값입니다.
모델의 roleNames()이 textRole에 지정된 역할을 제공하지 않으면 경고가 표시됩니다. textRole을 설정하여 이 경고를 비활성화할 수 있습니다.
QAbstractItemModel::roleNames()도 참조하십시오 .
© 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.