aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2025-12-15 16:14:22 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2025-12-15 16:14:22 +0200
commitb58ec3b086518da5aa573f99426235854c23e35f (patch)
tree861a9935d8f1cdba2fdca546836a351736dbddbf /src/quick/doc/snippets/qml
parent4826f86e274f1b29bd769e6790824f9e62a40f62 (diff)
parent22032227d16c39211e2ebceef97d21f4d89c7c87 (diff)
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'src/quick/doc/snippets/qml')
-rw-r--r--src/quick/doc/snippets/qml/listview/hideDelegate.qml27
-rw-r--r--src/quick/doc/snippets/qml/listview/listview.qml9
-rw-r--r--src/quick/doc/snippets/qml/listview/stateInDelegate.qml20
-rw-r--r--src/quick/doc/snippets/qml/listview/stateInModel.qml26
4 files changed, 80 insertions, 2 deletions
diff --git a/src/quick/doc/snippets/qml/listview/hideDelegate.qml b/src/quick/doc/snippets/qml/listview/hideDelegate.qml
new file mode 100644
index 0000000000..7c019a2c92
--- /dev/null
+++ b/src/quick/doc/snippets/qml/listview/hideDelegate.qml
@@ -0,0 +1,27 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls.Basic
+
+//! [ListView]
+ListView {
+ anchors.fill: parent
+ model: ListModel {
+ ListElement { hidden: false }
+ ListElement { hidden: false }
+ ListElement { hidden: false }
+ // ...
+ }
+ delegate: ItemDelegate {
+ text: qsTr("Item %1").arg(index)
+ visible: !model.hidden
+ height: visible ? implicitHeight : 0
+
+ required property int index
+ required property var model
+
+ onClicked: model.hidden = true
+ }
+}
+//! [ListView]
diff --git a/src/quick/doc/snippets/qml/listview/listview.qml b/src/quick/doc/snippets/qml/listview/listview.qml
index c8df8e727b..611f590542 100644
--- a/src/quick/doc/snippets/qml/listview/listview.qml
+++ b/src/quick/doc/snippets/qml/listview/listview.qml
@@ -13,6 +13,8 @@ ListView {
model: ContactModel {}
delegate: Text {
+ required property string name
+ required property string number
text: name + ": " + number
}
}
@@ -25,10 +27,13 @@ Rectangle {
Component {
id: contactDelegate
Item {
+ id: myItem
+ required property string name
+ required property string number
width: 180; height: 40
Column {
- Text { text: '<b>Name:</b> ' + name }
- Text { text: '<b>Number:</b> ' + number }
+ Text { text: '<b>Name:</b> ' + myItem.name }
+ Text { text: '<b>Number:</b> ' + myItem.number }
}
}
}
diff --git a/src/quick/doc/snippets/qml/listview/stateInDelegate.qml b/src/quick/doc/snippets/qml/listview/stateInDelegate.qml
new file mode 100644
index 0000000000..29d8d3e7c2
--- /dev/null
+++ b/src/quick/doc/snippets/qml/listview/stateInDelegate.qml
@@ -0,0 +1,20 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls.Basic
+
+//! [ListView]
+ListView {
+ anchors.fill: parent
+ model: 3
+ delegate: CheckDelegate {
+ text: qsTr("Channel %1").arg(index + 1)
+
+ required property int index
+ property bool channelActivated
+
+ onClicked: channelActivated = checked
+ }
+}
+//! [ListView]
diff --git a/src/quick/doc/snippets/qml/listview/stateInModel.qml b/src/quick/doc/snippets/qml/listview/stateInModel.qml
new file mode 100644
index 0000000000..56b2792140
--- /dev/null
+++ b/src/quick/doc/snippets/qml/listview/stateInModel.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls.Basic
+
+//! [ListView]
+ListView {
+ anchors.fill: parent
+ model: ListModel {
+ ListElement {
+ channelActivated: true
+ }
+ // ...
+ }
+ delegate: CheckDelegate {
+ text: qsTr("Channel %1").arg(index + 1)
+ checked: model.channelActivated
+
+ required property int index
+ required property var model
+
+ onClicked: model.channelActivated = checked
+ }
+}
+//! [ListView]