aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickcheckbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates/qquickcheckbox.cpp')
-rw-r--r--src/templates/qquickcheckbox.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/templates/qquickcheckbox.cpp b/src/templates/qquickcheckbox.cpp
index 644e151e..945fbc42 100644
--- a/src/templates/qquickcheckbox.cpp
+++ b/src/templates/qquickcheckbox.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickCheckBox
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief A check box control.
+ \brief An option button that can be checked or unchecked.
CheckBox presents an option button that can be toggled on (checked) or
off (unchecked). Check boxes are typically used to select one or more
@@ -121,10 +121,11 @@ bool QQuickCheckBox::isTristate() const
void QQuickCheckBox::setTristate(bool tristate)
{
Q_D(QQuickCheckBox);
- if (d->tristate != tristate) {
- d->tristate = tristate;
- emit tristateChanged();
- }
+ if (d->tristate == tristate)
+ return;
+
+ d->tristate = tristate;
+ emit tristateChanged();
}
/*!
@@ -148,16 +149,18 @@ Qt::CheckState QQuickCheckBox::checkState() const
void QQuickCheckBox::setCheckState(Qt::CheckState state)
{
Q_D(QQuickCheckBox);
+ if (d->checkState == state)
+ return;
+
if (!d->tristate && state == Qt::PartiallyChecked)
setTristate(true);
- if (d->checkState != state) {
- bool wasChecked = isChecked();
- d->checked = state != Qt::Unchecked;
- d->checkState = state;
- emit checkStateChanged();
- if (d->checked != wasChecked)
- emit checkedChanged();
- }
+
+ bool wasChecked = isChecked();
+ d->checked = state != Qt::Unchecked;
+ d->checkState = state;
+ emit checkStateChanged();
+ if (d->checked != wasChecked)
+ emit checkedChanged();
}
QFont QQuickCheckBox::defaultFont() const