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
qquickroundbutton.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
"qquickroundbutton_p.h"
6
7
#
include
<
QtQuickTemplates2
/
private
/
qquickbutton_p_p
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
/*!
12
\qmltype RoundButton
13
\inherits Button
14
//! \nativetype QQuickRoundButton
15
\inqmlmodule QtQuick.Controls
16
\since 5.8
17
\ingroup qtquickcontrols-buttons
18
\brief A push-button control with rounded corners that can be clicked by the user.
19
20
\image qtquickcontrols-roundbutton.png
21
{Round button control}
22
23
RoundButton is identical to \l Button, except that it has a \l radius property
24
which allows the corners to be rounded without having to customize the
25
\l background.
26
27
\snippet qtquickcontrols-roundbutton.qml 1
28
29
\sa {Customizing RoundButton}, {Button Controls}
30
*/
31
32
class
QQuickRoundButtonPrivate
:
public
QQuickButtonPrivate
33
{
34
Q_DECLARE_PUBLIC(QQuickRoundButton)
35
36
public
:
37
void
setRadius
(
qreal
newRadius
= -1.0);
38
39
qreal
radius
= 0;
40
bool
explicitRadius
=
false
;
41
};
42
43
void
QQuickRoundButtonPrivate
::setRadius(qreal newRadius)
44
{
45
Q_Q(QQuickRoundButton);
46
const
qreal oldRadius = radius;
47
if
(newRadius < 0)
48
radius = qMax<qreal>(0, qMin<qreal>(width, height) / 2);
49
else
50
radius = newRadius;
51
52
if
(!qFuzzyCompare(radius, oldRadius))
53
emit q->radiusChanged();
54
}
55
56
QQuickRoundButton::QQuickRoundButton(QQuickItem *parent)
57
: QQuickButton(*(
new
QQuickRoundButtonPrivate), parent)
58
{
59
}
60
61
/*!
62
\qmlproperty real QtQuick.Controls::RoundButton::radius
63
64
This property holds the radius of the button.
65
66
To create a relatively square button that has slightly rounded corners,
67
use a small value, such as \c 3.
68
69
To create a completely circular button (the default), use a value that is
70
equal to half of the width or height of the button, and make the button's
71
width and height identical.
72
73
To reset this property back to the default value, set its value to
74
\c undefined.
75
*/
76
qreal QQuickRoundButton::radius()
const
77
{
78
Q_D(
const
QQuickRoundButton);
79
return
d->radius;
80
}
81
82
void
QQuickRoundButton::setRadius(qreal radius)
83
{
84
Q_D(QQuickRoundButton);
85
d->explicitRadius =
true
;
86
d->setRadius(radius);
87
}
88
89
void
QQuickRoundButton::resetRadius()
90
{
91
Q_D(QQuickRoundButton);
92
d->explicitRadius =
false
;
93
d->setRadius();
94
}
95
96
void
QQuickRoundButton::geometryChange(
const
QRectF &newGeometry,
const
QRectF &oldGeometry)
97
{
98
Q_D(QQuickRoundButton);
99
QQuickControl::geometryChange(newGeometry, oldGeometry);
100
if
(!d->explicitRadius)
101
d->setRadius();
102
}
103
104
QT_END_NAMESPACE
105
106
#
include
"moc_qquickroundbutton_p.cpp"
QQuickRoundButtonPrivate
A push-button control with rounded corners that can be clicked by the user.
Definition
qquickroundbutton.cpp:33
QQuickRoundButtonPrivate::explicitRadius
bool explicitRadius
Definition
qquickroundbutton.cpp:40
QQuickRoundButtonPrivate::radius
qreal radius
Definition
qquickroundbutton.cpp:39
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtdeclarative
src
quicktemplates
qquickroundbutton.cpp
Generated on
for Qt by
1.16.1