Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickheaderviewdelegate.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
7#include <QtQuickTemplates2/private/qquickheaderview_p.h>
8#include <QtQuickTemplates2/private/qquickheaderview_p_p.h>
9#include <QtQuickTemplates2/private/qquicktableviewdelegate_p_p.h>
10
11/*!
12 \qmltype HorizontalHeaderViewDelegate
13 \inherits TableViewDelegate
14 \inqmlmodule QtQuick.Controls
15 \since 6.10
16 \ingroup qtquickcontrols-delegates
17
18 \image qtquickcontrols-headerviewdelegate.png
19
20 The HorizontalHeaderViewDelegate serves as the default delegate
21 automatically assigned to the \l HorizontalHeaderView's
22 \l {TableView::delegate} {delegate property}.
23 This delegate handles rendering every header cell using the
24 application's predefined style specifications.
25
26 HorizontalHeaderViewDelegate inherits TableViewDelegate, which means
27 that it's composed of two items:
28 a \l[QML]{Control::}{background} and
29 a \l [QML]{Control::}{contentItem}.
30
31 \sa {Customizing HeaderViewDelegate}, {HorizontalHeaderView}
32*/
33
34/*!
35 \qmltype VerticalHeaderViewDelegate
36 \inherits TableViewDelegate
37 \inqmlmodule QtQuick.Controls
38 \since 6.10
39 \ingroup qtquickcontrols-delegates
40
41 \image qtquickcontrols-headerviewdelegate.png
42
43 The VerticalHeaderViewDelegate serves as the default delegate
44 automatically assigned to the \l VerticalHeaderView's
45 \l {TableView::delegate} {delegate property}.
46 This delegate handles rendering every header cell using the
47 application's predefined style specifications.
48
49 VerticalHeaderViewDelegate inherits TableViewDelegate, which means
50 that it's composed of two items:
51 a \l[QML]{Control::}{background} and
52 a \l [QML]{Control::}{contentItem}.
53
54 \sa {Customizing HeaderViewDelegate}, {VerticalHeaderView}
55*/
56
57/*!
58 \qmlproperty HeaderView QtQuick.Controls::HorizontalHeaderViewDelegate::headerView
59
60 This property points to the \l HorizontalHeaderView that contains the delegate item.
61*/
62
63/*!
64 \qmlproperty HeaderView QtQuick.Controls::VerticalHeaderViewDelegate::headerView
65
66 This property points to the \l VerticalHeaderView that contains the delegate item.
67*/
68
69/*!
70 \qmlproperty Qt::Orientations QtQuick.Controls::HorizontalHeaderViewDelegate::orientation
71
72 This property has the same value of the headerView's orientation.
73*/
74
75/*!
76 \qmlproperty Qt::Orientations QtQuick.Controls::VerticalHeaderViewDelegate::orientation
77
78 This property has the same value of the headerView's orientation.
79*/
80
81
83
85{
86public:
87 Q_DECLARE_PUBLIC(QQuickHeaderViewDelegate)
88
89public:
92};
93
94QQuickHeaderViewDelegate::QQuickHeaderViewDelegate(QQuickItem *parent)
95 : QQuickTableViewDelegate(*(new QQuickHeaderViewDelegatePrivate), parent)
96{
97}
98
99QQuickHeaderViewBase *QQuickHeaderViewDelegate::headerView() const
100{
101 return d_func()->headerView;
102}
103
104Qt::Orientation QQuickHeaderViewDelegate::orientation() const
105{
106 return headerView()
107 ? QQuickHeaderViewBasePrivate::get(headerView())->orientation()
108 : Qt::Horizontal;
109}
110
111void QQuickHeaderViewDelegate::setHeaderView(QQuickHeaderViewBase *headerView)
112{
113 Q_D(QQuickHeaderViewDelegate);
114 if (d->headerView == headerView)
115 return;
116
117 const Qt::Orientation oldOrientation = orientation();
118
119 d->headerView = headerView;
120 emit headerViewChanged();
121
122 if (oldOrientation != orientation())
123 emit orientationChanged();
124}
125
126QVariant QQuickHeaderViewDelegate::model() const
127{
128 return d_func()->model;
129}
130
131void QQuickHeaderViewDelegate::setModel(const QVariant &model)
132{
133 Q_D(QQuickHeaderViewDelegate);
134 if (d->model == model)
135 return;
136 d->model = model;
137 emit modelChanged();
138}
139
140QT_END_NAMESPACE
141
142#include "moc_qquickheaderviewdelegate_p.cpp"
\qmltype HorizontalHeaderViewDelegate \inherits TableViewDelegate \inqmlmodule QtQuick....