8#include <QtGui/qpa/qplatformtheme.h>
9#include <QtQml/qjsvalue.h>
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
70 Q_DECLARE_PUBLIC(QQuickCheckBox)
80QQuickCheckBox::QQuickCheckBox(QQuickItem *parent)
81 : QQuickAbstractButton(*(
new QQuickCheckBoxPrivate), parent)
87
88
89
90
91
92
93
94
95
96
97bool QQuickCheckBox::isTristate()
const
99 Q_D(
const QQuickCheckBox);
103void QQuickCheckBox::setTristate(
bool tristate)
106 if (d->tristate == tristate)
109 d->tristate = tristate;
110 emit tristateChanged();
114
115
116
117
118
119
120
121
122
123
124
125Qt::CheckState QQuickCheckBox::checkState()
const
127 Q_D(
const QQuickCheckBox);
128 return d->checkState;
131void QQuickCheckBox::setCheckState(Qt::CheckState state)
134 if (d->checkState == state)
137 bool wasChecked = isChecked();
138 d->checked = state == Qt::Checked;
139 d->checkState = state;
140 emit checkStateChanged();
141 if (d->checked != wasChecked)
142 emit checkedChanged();
145QJSValue QQuickCheckBox::getNextCheckState()
const
147 Q_D(
const QQuickCheckBox);
148 return d->nextCheckState;
151void QQuickCheckBox::setNextCheckState(
const QJSValue &callback)
154 d->nextCheckState = callback;
155 emit nextCheckStateChanged();
158QFont QQuickCheckBox::defaultFont()
const
160 return QQuickTheme::font(QQuickTheme::CheckBox);
163void QQuickCheckBox::buttonChange(ButtonChange change)
165 if (change == ButtonCheckedChange)
166 setCheckState(isChecked() ? Qt::Checked : Qt::Unchecked);
168 QQuickAbstractButton::buttonChange(change);
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204void QQuickCheckBox::nextCheckState()
207 if (d->nextCheckState.isCallable())
208 setCheckState(
static_cast<Qt::CheckState>(d->nextCheckState.call().toInt()));
209 else if (d->tristate)
210 setCheckState(
static_cast<Qt::CheckState>((d->checkState + 1) % 3));
212 QQuickAbstractButton::nextCheckState();
217#include "moc_qquickcheckbox_p.cpp"
Check button that can be toggled on or off.
Qt::CheckState checkState