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
void
QQuickItemDelegatePrivate::init()
38
{
39
Q_Q(QQuickItemDelegate);
40
q->setFocusPolicy(Qt::NoFocus);
41
setMnemonicEnabled(
false
);
42
}
43
44
QPalette QQuickItemDelegatePrivate::defaultPalette()
const
45
{
46
return
QQuickTheme::palette(QQuickTheme::ItemView);
47
}
48
49
QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent)
50
: QQuickAbstractButton(*(
new
QQuickItemDelegatePrivate), parent)
51
{
52
d_func()->init();
53
}
54
55
QQuickItemDelegate::QQuickItemDelegate(QQuickItemDelegatePrivate &dd, QQuickItem *parent)
56
: QQuickAbstractButton(dd, parent)
57
{
58
d_func()->init();
59
}
60
61
/*!
62
\qmlproperty bool QtQuick.Controls::ItemDelegate::highlighted
63
64
This property holds whether the delegate is highlighted.
65
66
A delegate can be highlighted in order to draw the user's attention towards
67
it. It has no effect on keyboard interaction. For example, you can
68
highlight the current item in a ListView using the following code:
69
70
\code
71
ListView {
72
id: listView
73
model: 10
74
delegate: ItemDelegate {
75
text: index
76
highlighted: ListView.isCurrentItem
77
78
required property int index
79
80
onClicked: listView.currentIndex = index
81
}
82
}
83
\endcode
84
85
The default value is \c false.
86
*/
87
bool
QQuickItemDelegate::isHighlighted()
const
88
{
89
Q_D(
const
QQuickItemDelegate);
90
return
d->highlighted;
91
}
92
93
void
QQuickItemDelegate::setHighlighted(
bool
highlighted)
94
{
95
Q_D(QQuickItemDelegate);
96
if
(highlighted == d->highlighted)
97
return
;
98
99
d->highlighted = highlighted;
100
emit highlightedChanged();
101
}
102
103
QFont QQuickItemDelegate::defaultFont()
const
104
{
105
return
QQuickTheme::font(QQuickTheme::ItemView);
106
}
107
108
#
if
QT_CONFIG
(
accessibility
)
109
QAccessible::Role QQuickItemDelegate::accessibleRole()
const
110
{
111
return
QAccessible::ListItem;
112
}
113
#
endif
114
115
QT_END_NAMESPACE
116
117
#
include
"moc_qquickitemdelegate_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quicktemplates
qquickitemdelegate.cpp
Generated on
for Qt by
1.16.1