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
qquickcheckdelegate.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
6
7#include <QtGui/qpa/qplatformtheme.h>
8#include <QtQml/qjsvalue.h>
9
11
16
67
69{
71 nextCheckState = callback;
72 emit q->nextCheckStateChanged();
73}
74
75QQuickCheckDelegate::QQuickCheckDelegate(QQuickItem *parent)
77{
78 setCheckable(true);
79}
80
92bool QQuickCheckDelegate::isTristate() const
93{
94 Q_D(const QQuickCheckDelegate);
95 return d->tristate;
96}
97
98void QQuickCheckDelegate::setTristate(bool tristate)
99{
101 if (d->tristate == tristate)
102 return;
103
104 d->tristate = tristate;
106}
107
121{
122 Q_D(const QQuickCheckDelegate);
123 return d->checkState;
124}
125
126void QQuickCheckDelegate::setCheckState(Qt::CheckState state)
127{
129 if (d->checkState == state)
130 return;
131
132 bool wasChecked = isChecked();
133 d->checked = state == Qt::Checked;
134 d->checkState = state;
136 if (d->checked != wasChecked)
138}
139
144
146{
147 if (change == ButtonCheckedChange)
148 setCheckState(isChecked() ? Qt::Checked : Qt::Unchecked);
149 else
151}
152
187{
189 if (d->nextCheckState.isCallable())
190 setCheckState(static_cast<Qt::CheckState>(d->nextCheckState.call().toInt()));
191 else if (d->tristate)
192 setCheckState(static_cast<Qt::CheckState>((d->checkState + 1) % 3));
193 else
195}
196
197#if QT_CONFIG(accessibility)
198QAccessible::Role QQuickCheckDelegate::accessibleRole() const
199{
200 return QAccessible::CheckBox;
201}
202#endif
203
205
206#include "moc_qquickcheckdelegate_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
virtual void buttonChange(ButtonChange change)
Item delegate with a check indicator that can be toggled on or off.
QPalette defaultPalette() const override
void setNextCheckState(const QJSValue &callback)
QFont defaultFont() const override
void buttonChange(ButtonChange change) override
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
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
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define emit