diff options
| author | Mitch Curtis <mitch.curtis@qt.io> | 2024-11-19 10:50:18 +0800 |
|---|---|---|
| committer | Mitch Curtis <mitch.curtis@qt.io> | 2024-11-28 16:40:47 +0800 |
| commit | e7286e3f5fcabc921fc794f7099c9da4e8ceb01b (patch) | |
| tree | 3ea89c27dc54f721f0548a5295ac442f9c9a55d2 /src/quick/doc/snippets | |
| parent | 473fc5005e2811347f00679e56e90ec0915f8041 (diff) | |
Doc: add "Hiding Delegates" section to ListView's docs
This comes up often online, so let's document the official advice.
Pick-to: 6.5 6.8
Change-Id: I926326bc3b033d38746a508e5c448b5b055effeb
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/quick/doc/snippets')
| -rw-r--r-- | src/quick/doc/snippets/qml/listview/hideDelegate.qml | 27 |
1 files changed, 27 insertions, 0 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] |
