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