2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2020 The Qt Company Ltd.
|
2024-02-22 14:51:16 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2019-04-11 15:30:49 +00:00
|
|
|
|
2020-03-26 16:01:51 +00:00
|
|
|
import QtQml.Models
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Shapes
|
|
|
|
import QtQuick.Window
|
|
|
|
import Qt.labs.qmlmodels
|
|
|
|
import TestTableModelWithHeader
|
2019-04-11 15:30:49 +00:00
|
|
|
|
|
|
|
Window {
|
|
|
|
visible: true
|
|
|
|
width: 640
|
|
|
|
height: 480
|
|
|
|
title: qsTr("HeaderView Test")
|
2023-02-09 12:50:45 +00:00
|
|
|
color: Qt.styleHints.colorScheme === Qt.Light ? palette.mid : palette.midlight
|
2019-04-11 15:30:49 +00:00
|
|
|
|
|
|
|
TestTableModelWithHeader {
|
|
|
|
id: tableModel
|
|
|
|
rowCount: 50
|
|
|
|
columnCount: 80
|
|
|
|
}
|
|
|
|
|
|
|
|
TableView {
|
|
|
|
id: tableView
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: horizontalHeader.height + rowSpacing
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: verticalHeader.width + columnSpacing
|
|
|
|
model: tableModel
|
|
|
|
rightMargin: 100
|
|
|
|
bottomMargin: 100
|
2023-01-12 15:16:25 +00:00
|
|
|
columnSpacing: 1
|
|
|
|
rowSpacing: 1
|
2019-04-11 15:30:49 +00:00
|
|
|
syncDirection: Qt.Vertical | Qt.Horizontal
|
|
|
|
implicitWidth: parent.width + columnSpacing
|
|
|
|
implicitHeight: parent.height + rowSpacing
|
|
|
|
clip: true
|
|
|
|
delegate: Rectangle {
|
|
|
|
implicitWidth: 150
|
|
|
|
implicitHeight: 50
|
2023-01-12 15:16:25 +00:00
|
|
|
color: tableView.palette.base
|
2019-04-11 15:30:49 +00:00
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
anchors.fill: parent
|
|
|
|
text: model.display
|
|
|
|
checked: model.edit
|
|
|
|
leftPadding: 12
|
|
|
|
onClicked: model.edit = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HorizontalHeaderView {
|
|
|
|
id: horizontalHeader
|
|
|
|
objectName: "horizontalHeader"
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: tableView.left
|
|
|
|
syncView: tableView
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
|
|
|
VerticalHeaderView {
|
|
|
|
id: verticalHeader
|
|
|
|
objectName: "verticalHeader"
|
|
|
|
anchors.top: tableView.top
|
|
|
|
syncView: tableView
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
2023-01-12 15:16:25 +00:00
|
|
|
Rectangle {
|
2019-04-11 15:30:49 +00:00
|
|
|
width: verticalHeader.width
|
|
|
|
height: horizontalHeader.height
|
2023-01-12 15:16:25 +00:00
|
|
|
color: palette.base
|
|
|
|
ToolButton {
|
|
|
|
anchors.fill: parent
|
|
|
|
text: "<<"
|
|
|
|
onClicked: {
|
|
|
|
horizontalHeader.contentX = 0
|
|
|
|
verticalHeader.contentY = 0
|
|
|
|
}
|
2019-04-11 15:30:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|