Kirigami2

ListSectionHeader.qml
1/*
2 * SPDX-FileCopyrightText: 2019 Björn Feber <bfeber@protonmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7import QtQuick
8import QtQuick.Controls as QQC2
9import QtQuick.Layouts
10import org.kde.kirigami as Kirigami
11
12/**
13 * @brief A section delegate for the primitive ListView component.
14 *
15 * It's intended to make all listviews look coherent.
16 *
17 * Any additional content items will be positioned in a row at the trailing side
18 * of this component.
19 *
20 * Example usage:
21 * @code
22 * import QtQuick
23 * import QtQuick.Controls as QQC2
24 * import org.kde.kirigami as Kirigami
25 *
26 * ListView {
27 * section.delegate: Kirigami.ListSectionHeader {
28 * text: section
29 *
30 * QQC2.Button {
31 * text: "Button 1"
32 * }
33 * QQC2.Button {
34 * text: "Button 2"
35 * }
36 * }
37 * }
38 * @endcode
39 */
40QQC2.ItemDelegate {
41 id: listSection
42
43 /**
44 * @brief This property sets the text of the ListView's section header.
45 * @property string label
46 * @deprecated since 6.2 Use base type's AbstractButton::text property directly
47 */
48 @Deprecated { reason: "Use base type's AbstractButton::text property directly" }
49 property alias label: listSection.text
50
51 default property alias _contents: rowLayout.data
52
53 hoverEnabled: false
54
55 activeFocusOnTab: false
56
57 // we do not need a background
58 background: Item {}
59
60 topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
61
62 Accessible.role: Accessible.Heading
63
64 contentItem: RowLayout {
65 id: rowLayout
66 spacing: Kirigami.Units.largeSpacing
67
68 Kirigami.Heading {
69 Layout.maximumWidth: rowLayout.width
70 Layout.alignment: Qt.AlignVCenter
71
72 opacity: 0.7
73 level: 5
74 type: Kirigami.Heading.Primary
75 text: listSection.text
76 elide: Text.ElideRight
77
78 // we override the Primary type's font weight (DemiBold) for Bold for contrast with small text
79 font.weight: Font.Bold
80
81 Accessible.ignored: true
82 }
83
84 Kirigami.Separator {
85 Layout.fillWidth: true
86 Layout.alignment: Qt.AlignVCenter
87 Accessible.ignored: true
88 }
89 }
90}
Type type(const QSqlDatabase &db)
QStringView level(QStringView ifopt)
QChar * data()
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 11:55:36 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.