diff options
Diffstat (limited to 'src/quick/doc/snippets')
| -rw-r--r-- | src/quick/doc/snippets/qml/listview/stateInDelegate.qml | 20 | ||||
| -rw-r--r-- | src/quick/doc/snippets/qml/listview/stateInModel.qml | 26 |
2 files changed, 46 insertions, 0 deletions
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] |
