aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/doc/snippets/qtquickcontrols-headerview.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/quickcontrols/doc/snippets/qtquickcontrols-headerview.qml')
-rw-r--r--src/quickcontrols/doc/snippets/qtquickcontrols-headerview.qml79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/quickcontrols/doc/snippets/qtquickcontrols-headerview.qml b/src/quickcontrols/doc/snippets/qtquickcontrols-headerview.qml
new file mode 100644
index 0000000000..b8f6935010
--- /dev/null
+++ b/src/quickcontrols/doc/snippets/qtquickcontrols-headerview.qml
@@ -0,0 +1,79 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//![0]
+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: Qt.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
+ }
+ }
+ }
+ }
+//![0]
+}