VerticalHeaderView QML Type

TableView...에 수반되는 세로 헤더 보기를 제공합니다... .

Import Statement: import QtQuick.Controls
Inherits:

TableView

속성

자세한 설명

수직 헤더 뷰는 스타일이 지정된 테이블 헤더를 제공합니다. 독립적인 뷰로 사용하거나 TableView 의 헤더로 사용할 수 있습니다.

VerticalHeaderView의 syncView 속성에 TableView 을 할당하여 TableView 에 대한 헤더를 추가할 수 있습니다. 그러면 플릭하는 동안 헤더와 테이블이 동기화 상태로 유지됩니다.

기본적으로 VerticalHeaderView는 sync view's model 에서 header data 을 표시합니다. 해당 모델의 헤더 데이터를 사용하지 않거나 syncView 을 사용하지 않으려면 model 속성에 모델을 명시적으로 할당할 수 있습니다.

참고: QAbstractItemModel 의 헤더 데이터를 표시하기 위해 수직헤더뷰는 내부적으로 모델의 헤더 데이터를 독립적인 프록시 모델에 래핑합니다. 이 모델은 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
                }
            }
        }
    }
}

수직 머리글 뷰는 기본적으로 resizableColumnstrue 로 설정됩니다.

HorizontalHeaderView참조하세요 .

속성 문서

model : QVariant

이 속성은 세로형 머리글 보기에 데이터를 제공하는 모델을 보유합니다.

기본적으로 세로형 헤더 뷰는 sync view's model 에서 header data 을 표시합니다. 해당 모델의 헤더 데이터를 사용하지 않거나 syncView 를 사용하지 않으려면 이 속성에 모델을 명시적으로 지정할 수 있습니다. modelQAbstractTableModel 인 경우 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의 모델을 사용하여 열에 레이블을 지정합니다.

modelTableView참조하세요 .


textRole : string

이 속성은 각 헤더 셀에 텍스트를 표시하는 데 사용되는 모델 역할을 보유합니다.

모델에 여러 역할이 있는 경우 textRole을 설정하여 표시할 역할을 결정할 수 있습니다.

모델이 QAbstractItemModel 인 경우 기본값은 "표시"이며, 그렇지 않으면 비어 있습니다.

모델의 roleNames()가 textRole에 지정된 역할을 제공하지 않으면 경고가 표시됩니다. textRole을 설정하여 경고를 무음으로 설정할 수 있습니다.

QAbstractItemModel::roleNames()도 참조하세요 .


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