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
qquickradiobutton.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
"qquickradiobutton_p.h"
6
#
include
"qquickcontrol_p_p.h"
7
#
include
"qquickabstractbutton_p_p.h"
8
9
#
include
<
QtGui
/
qpa
/
qplatformtheme
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
/*!
14
\qmltype RadioButton
15
\inherits AbstractButton
16
//! \nativetype QQuickRadioButton
17
\inqmlmodule QtQuick.Controls
18
\since 5.7
19
\ingroup qtquickcontrols-buttons
20
\brief Exclusive radio button that can be toggled on or off.
21
22
\image qtquickcontrols-radiobutton.gif
23
{Radio buttons showing exclusive selection behavior}
24
25
RadioButton presents an option button that can be toggled on (checked) or
26
off (unchecked). Radio buttons are typically used to select one option
27
from a set of options.
28
29
RadioButton inherits its API from \l AbstractButton. For instance,
30
you can set \l {AbstractButton::text}{text} and react to
31
\l {AbstractButton::clicked}{clicks} using the AbstractButton API.
32
The state of the radio button can be set with the
33
\l {AbstractButton::}{checked} property.
34
35
Radio buttons are \l {AbstractButton::autoExclusive}{auto-exclusive}
36
by default. Only one button can be checked at any time amongst radio
37
buttons that belong to the same parent item; checking another button
38
automatically unchecks the previously checked one. For radio buttons
39
that do not share a common parent, ButtonGroup can be used to manage
40
exclusivity.
41
42
\l RadioDelegate is similar to RadioButton, except that it is typically
43
used in views.
44
45
\code
46
ColumnLayout {
47
RadioButton {
48
checked: true
49
text: qsTr("First")
50
}
51
RadioButton {
52
text: qsTr("Second")
53
}
54
RadioButton {
55
text: qsTr("Third")
56
}
57
}
58
\endcode
59
60
\sa ButtonGroup, {Customizing RadioButton}, {Button Controls}, RadioDelegate
61
*/
62
63
class
Q_QUICKTEMPLATES2_EXPORT
QQuickRadioButtonPrivate
:
public
QQuickAbstractButtonPrivate
64
{
65
Q_DECLARE_PUBLIC(QQuickRadioButton)
66
67
public
:
68
QPalette defaultPalette()
const
override {
return
QQuickTheme::palette(QQuickTheme::RadioButton); }
69
};
70
71
QQuickRadioButton::QQuickRadioButton(QQuickItem *parent)
72
: QQuickAbstractButton(*(
new
QQuickRadioButtonPrivate), parent)
73
{
74
setCheckable(
true
);
75
setAutoExclusive(
true
);
76
}
77
78
QFont QQuickRadioButton::defaultFont()
const
79
{
80
return
QQuickTheme::font(QQuickTheme::RadioButton);
81
}
82
83
#
if
QT_CONFIG
(
accessibility
)
84
QAccessible::Role QQuickRadioButton::accessibleRole()
const
85
{
86
return
QAccessible::RadioButton;
87
}
88
#
endif
89
90
QT_END_NAMESPACE
91
92
#
include
"moc_qquickradiobutton_p.cpp"
QQuickRadioButtonPrivate
Exclusive radio button that can be toggled on or off.
Definition
qquickradiobutton.cpp:64
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtdeclarative
src
quicktemplates
qquickradiobutton.cpp
Generated on
for Qt by
1.16.1