aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/tableview/qml-tablemodel.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/doc/snippets/qml/tableview/qml-tablemodel.qml')
-rw-r--r--src/quick/doc/snippets/qml/tableview/qml-tablemodel.qml45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/qml/tableview/qml-tablemodel.qml b/src/quick/doc/snippets/qml/tableview/qml-tablemodel.qml
new file mode 100644
index 0000000000..f0a28a4be6
--- /dev/null
+++ b/src/quick/doc/snippets/qml/tableview/qml-tablemodel.qml
@@ -0,0 +1,45 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//![0]
+import QtQuick
+import Qt.labs.qmlmodels
+
+TableView {
+ anchors.fill: parent
+ columnSpacing: 1
+ rowSpacing: 1
+ clip: true
+
+ 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: 50
+ border.width: 1
+
+ Text {
+ text: display
+ anchors.centerIn: parent
+ }
+ }
+}
+//![0]