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