Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickcheckbox.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
4#include "qquickcheckbox_p.h"
6
7#include <QtGui/qpa/qplatformtheme.h>
8#include <QtQml/qjsvalue.h>
9
11
16
78
84
97{
98 Q_D(const QQuickCheckBox);
99 return d->tristate;
100}
101
103{
104 Q_D(QQuickCheckBox);
105 if (d->tristate == tristate)
106 return;
107
108 d->tristate = tristate;
110}
111
125{
126 Q_D(const QQuickCheckBox);
127 return d->checkState;
128}
129
131{
132 Q_D(QQuickCheckBox);
133 if (d->checkState == state)
134 return;
135
136 bool wasChecked = isChecked();
137 d->checked = state == Qt::Checked;
138 d->checkState = state;
140 if (d->checked != wasChecked)
142}
143
145{
146 Q_D(const QQuickCheckBox);
147 return d->nextCheckState;
148}
149
151{
152 Q_D(QQuickCheckBox);
153 d->nextCheckState = callback;
154 emit nextCheckStateChanged();
155}
156
161
169
204{
205 Q_D(QQuickCheckBox);
206 if (d->nextCheckState.isCallable())
207 setCheckState(static_cast<Qt::CheckState>(d->nextCheckState.call().toInt()));
208 else if (d->tristate)
209 setCheckState(static_cast<Qt::CheckState>((d->checkState + 1) % 3));
210 else
212}
213
215
216#include "moc_qquickcheckbox_p.cpp"
\reentrant
Definition qfont.h:22
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
bool isChecked() const
\qmlproperty bool QtQuick.Controls::AbstractButton::checked
void setCheckable(bool checkable)
virtual void buttonChange(ButtonChange change)
Check button that can be toggled on or off.
Qt::CheckState checkState
QPalette defaultPalette() const override
QFont defaultFont() const override
void buttonChange(ButtonChange change) override
void setTristate(bool tristate)
QJSValue getNextCheckState() const
QJSValue nextCheckState
void checkStateChanged()
void setNextCheckState(const QJSValue &callback)
void tristateChanged()
Qt::CheckState checkState
bool isTristate() const
\qmlproperty bool QtQuick.Controls::CheckBox::tristate
void setCheckState(Qt::CheckState state)
QQuickCheckBox(QQuickItem *parent=nullptr)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QString state() const
\qmlproperty string QtQuick::Item::state
static QPalette palette(Scope scope)
static QFont font(Scope scope)
else opt state
[0]
Combined button and popup list for selecting options.
CheckState
@ Unchecked
@ Checked
#define emit