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
qquickitemdelegate.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 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
5
#
include
"qquickitemdelegate_p.h"
6
#
include
"qquickitemdelegate_p_p.h"
7
#
include
"qquickcontrol_p_p.h"
8
9
#
include
<
QtGui
/
qpa
/
qplatformtheme
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
/*!
14
\qmltype ItemDelegate
15
\inherits AbstractButton
16
//! \nativetype QQuickItemDelegate
17
\inqmlmodule QtQuick.Controls
18
\since 5.7
19
\ingroup qtquickcontrols-delegates
20
\brief Basic item delegate that can be used in various views and controls.
21
22
\image qtquickcontrols-itemdelegate.gif
23
24
ItemDelegate presents a standard view item. It can be used as a delegate
25
in various views and controls, such as \l ListView and \l ComboBox.
26
27
ItemDelegate inherits its API from AbstractButton. For instance, you can set
28
\l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon},
29
and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API.
30
31
\snippet qtquickcontrols-itemdelegate.qml 1
32
33
\sa {Customizing ItemDelegate}, {Delegate Controls}
34
*/
35
36
QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent)
37
: QQuickAbstractButton(*(
new
QQuickItemDelegatePrivate), parent)
38
{
39
setFocusPolicy(Qt::NoFocus);
40
}
41
42
QQuickItemDelegate::QQuickItemDelegate(QQuickItemDelegatePrivate &dd, QQuickItem *parent)
43
: QQuickAbstractButton(dd, parent)
44
{
45
setFocusPolicy(Qt::NoFocus);
46
}
47
48
/*!
49
\qmlproperty bool QtQuick.Controls::ItemDelegate::highlighted
50
51
This property holds whether the delegate is highlighted.
52
53
A delegate can be highlighted in order to draw the user's attention towards
54
it. It has no effect on keyboard interaction. For example, you can
55
highlight the current item in a ListView using the following code:
56
57
\code
58
ListView {
59
id: listView
60
model: 10
61
delegate: ItemDelegate {
62
text: index
63
highlighted: ListView.isCurrentItem
64
65
required property int index
66
67
onClicked: listView.currentIndex = index
68
}
69
}
70
\endcode
71
72
The default value is \c false.
73
*/
74
bool
QQuickItemDelegate::isHighlighted()
const
75
{
76
Q_D(
const
QQuickItemDelegate);
77
return
d->highlighted;
78
}
79
80
void
QQuickItemDelegate::setHighlighted(
bool
highlighted)
81
{
82
Q_D(QQuickItemDelegate);
83
if
(highlighted == d->highlighted)
84
return
;
85
86
d->highlighted = highlighted;
87
emit highlightedChanged();
88
}
89
90
QFont QQuickItemDelegate::defaultFont()
const
91
{
92
return
QQuickTheme::font(QQuickTheme::ItemView);
93
}
94
95
#
if
QT_CONFIG
(
accessibility
)
96
QAccessible::Role QQuickItemDelegate::accessibleRole()
const
97
{
98
return
QAccessible::ListItem;
99
}
100
#
endif
101
102
QPalette QQuickItemDelegatePrivate::defaultPalette()
const
103
{
104
return
QQuickTheme::palette(QQuickTheme::ItemView);
105
}
106
107
QT_END_NAMESPACE
108
109
#
include
"moc_qquickitemdelegate_p.cpp"
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtdeclarative
src
quicktemplates
qquickitemdelegate.cpp
Generated on
for Qt by
1.14.0