aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/doc/snippets
diff options
context:
space:
mode:
authorMate Barany <mate.barany@qt.io>2025-07-01 15:01:34 +0200
committerMate Barany <mate.barany@qt.io>2025-07-17 10:48:20 +0000
commit5105235fc9f34b1528d107c0d0e724758cb96e52 (patch)
tree6cb54e041d5af52df1bb56c5c339ac4458dfefa8 /src/qmlmodels/doc/snippets
parent7dc433b193e3689141b6f9afcc834173a6ca597b (diff)
Extend documentation of QQmlTreeModel
Add the missing description of the class and some more snippets and examples. Task-number: QTBUG-137747 Pick-to: 6.10 Change-Id: Id4d84c22afe4562cbfff097238b9c3b20c184a84 Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
Diffstat (limited to 'src/qmlmodels/doc/snippets')
-rw-r--r--src/qmlmodels/doc/snippets/qml/treemodel/treemodel-filesystem-basic.qml100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/qmlmodels/doc/snippets/qml/treemodel/treemodel-filesystem-basic.qml b/src/qmlmodels/doc/snippets/qml/treemodel/treemodel-filesystem-basic.qml
new file mode 100644
index 0000000000..bcc52b3f08
--- /dev/null
+++ b/src/qmlmodels/doc/snippets/qml/treemodel/treemodel-filesystem-basic.qml
@@ -0,0 +1,100 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//![file]
+import QtQuick
+import QtQuick.Controls
+import Qt.labs.qmlmodels
+
+ApplicationWindow {
+ visible: true
+ width: 500
+ height: 500
+
+ TreeView {
+ id: treeView
+ anchors.fill: parent
+
+ selectionModel: ItemSelectionModel {}
+
+ model: TreeModel {
+ id: treeModel
+
+ TableModelColumn {
+ display: "checked"
+ }
+ TableModelColumn {
+ display: "size"
+ }
+ TableModelColumn {
+ display: "type"
+ }
+ TableModelColumn {
+ display: "name"
+ }
+ TableModelColumn {
+ display: "lastModified"
+ }
+
+ rows: [{
+ checked: false,
+ size: "—",
+ type: "folder",
+ name: "Documents",
+ lastModified: "2025-07-01",
+ rows: [{
+ checked: true,
+ size: "24 KB",
+ type: "file",
+ name: "Resume.pdf",
+ lastModified: "2025-06-20",
+ }, {
+ checked: false,
+ size: "2 MB",
+ type: "folder",
+ name: "Reports",
+ lastModified: "2025-06-10",
+ rows: [{
+ checked: true,
+ size: "850 KB",
+ type: "file",
+ name: "Q2_Report.docx",
+ lastModified: "2025-06-15",
+ }, {
+ checked: false,
+ size: "1.2 MB",
+ type: "file",
+ name: "Q3_Plan.xlsx",
+ lastModified: "2025-06-18",
+ }]
+ }]
+ },
+//![rows]
+ {
+ checked: false,
+ size: "—",
+ type: "folder",
+ name: "Pictures",
+ lastModified: "2025-05-30",
+ rows: [{
+ checked: true,
+ size: "3.5 MB",
+ type: "file",
+ name: "Vacation.jpg",
+ lastModified: "2025-05-15",
+ }, {
+ checked: false,
+ size: "2.1 MB",
+ type: "file",
+ name: "Family.png",
+ lastModified: "2025-05-20",
+ }]
+ }
+//![rows]
+ ]
+ }
+
+ delegate: TreeViewDelegate {}
+ }
+}
+//![file]