aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-03-07 10:21:53 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-04-08 07:42:08 +0000
commit7a303424f2095c53889f8102f115ec38013ef8d9 (patch)
tree883debcf88b5a9ce3da8acef37b86fc865f79294 /src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml
parent74313fd30a79e6f26734127157870c4491331501 (diff)
Add TableModelColumn
This allows us to support simple object rows by default, which we expect to be the most common use case for TableModel. Complex rows are supported, but with a limited subset of functionality. Things that could be improved: - Would be nice if we could get arbitrary/dynamic properties like ListModel has, without the complex code that comes with it. That way we could get rid of all of the role properties and users could have their own custom roles. The limitation of only having built-in roles becomes too restrictive very quickly. Change-Id: Icbdb6b39665851c55c69c0b79e0aa523c5d46dfe Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml')
-rw-r--r--src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml
index 5f00eb484b..f51c1818c3 100644
--- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml
+++ b/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -65,32 +65,37 @@ Window {
boundsBehavior: Flickable.StopAtBounds
model: TableModel {
+ TableModelColumn { display: "checked" }
+ TableModelColumn { display: "amount" }
+ TableModelColumn { display: "fruitType" }
+ TableModelColumn { display: "fruitName" }
+ TableModelColumn { display: "fruitPrice" }
+
// Each row is one type of fruit that can be ordered
//![rows]
rows: [
- [
- // Each object (line) is one cell/column,
- // and each property in that object is a role.
- { checked: false, checkable: true },
- { amount: 1 },
- { fruitType: "Apple" },
- { fruitName: "Granny Smith" },
- { fruitPrice: 1.50 }
- ],
- [
- { checked: true, checkable: true },
- { amount: 4 },
- { fruitType: "Orange" },
- { fruitName: "Navel" },
- { fruitPrice: 2.50 }
- ],
- [
- { checked: false, checkable: true },
- { amount: 1 },
- { fruitType: "Banana" },
- { fruitName: "Cavendish" },
- { fruitPrice: 3.50 }
- ]
+ {
+ // Each property is one cell/column.
+ checked: false,
+ amount: 1,
+ fruitType: "Apple",
+ fruitName: "Granny Smith",
+ fruitPrice: 1.50
+ },
+ {
+ checked: true,
+ amount: 4,
+ fruitType: "Orange",
+ fruitName: "Navel",
+ fruitPrice: 2.50
+ },
+ {
+ checked: false,
+ amount: 1,
+ fruitType: "Banana",
+ fruitName: "Cavendish",
+ fruitPrice: 3.50
+ }
]
//![rows]
}
@@ -100,7 +105,6 @@ Window {
padding: 12
selectByMouse: true
- // TODO: the property used here is undefined
onAccepted: model.display = text
Rectangle {