aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-06-10 08:36:24 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-06-10 13:30:21 +0200
commitc60dc57dda052f800ac5ea16c208c2c70b366358 (patch)
tree98bed0f3bbcce697464a3b193d96d3348c9e5666
parente20650e0702259b4be79be85a3d27e45db42efc1 (diff)
doc: update the selection model snippet
Fix up some minor issues in the documentation of selection support in TableView. Pick-to: 6.2 Change-Id: Ica2c0014f4e7f960332c283c1ff83a6b0bdd7df2 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
-rw-r--r--src/quick/doc/snippets/qml/tableview/selectionmodel.qml11
-rw-r--r--src/quick/items/qquicktableview.cpp9
2 files changed, 9 insertions, 11 deletions
diff --git a/src/quick/doc/snippets/qml/tableview/selectionmodel.qml b/src/quick/doc/snippets/qml/tableview/selectionmodel.qml
index b971e89979..8d7cb05f1c 100644
--- a/src/quick/doc/snippets/qml/tableview/selectionmodel.qml
+++ b/src/quick/doc/snippets/qml/tableview/selectionmodel.qml
@@ -62,17 +62,10 @@ Window {
visible: true
visibility: Window.AutomaticVisibility
- Button {
- id: button
- text: "Toggle"
- onClicked: tableView.selectionModel.select(tableView.model.index(0, 0), ItemSelectionModel.Toggle)
- }
-
//![0]
TableView {
id: tableView
anchors.fill: parent
- anchors.topMargin: button.height
clip: true
model: TableModel {
@@ -87,8 +80,10 @@ Window {
delegate: Rectangle {
implicitWidth: 100
implicitHeight: 30
+ color: selected ? "blue" : "lightgray"
+
required property bool selected
- color: selected ? "green" : "lightgray"
+
Text { text: display }
}
}
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 7ce92dc2e4..540f2edfde 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -190,7 +190,7 @@
\section1 Selecting items
- You can add selection support to TableView by assigning a QSelectionModel to
+ You can add selection support to TableView by assigning an ItemSelectionModel to
the \l selectionModel property. It will then use this model to control which
delegate items should be shown as selected. For a delegate item to be shown as
selected, it needs to contain the following property:
@@ -207,6 +207,9 @@
depending on the \c selected property:
\snippet qml/tableview/selectionmodel.qml 0
+
+ \note \l{Qt Quick Controls} offers a SelectionRectangle that can be used
+ to let the user select cells.
*/
/*!
@@ -425,14 +428,14 @@
*/
/*!
- \qmlproperty QSelectionModel QtQuick::TableView::selectionModel
+ \qmlproperty ItemSelectionModel QtQuick::TableView::selectionModel
This property can be set to control which delegate items should be shown as
selected. If the delegate has a \c {required property bool selected}
defined, TableView will keep it in sync with the selection state of the
corresponding model item in the selection model.
- \sa {Selecting items}
+ \sa {Selecting items}, SelectionRectangle
*/
/*!