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
67
68
72 Q_DECLARE_PUBLIC(QQuickCheckBox)
82QQuickCheckBox::QQuickCheckBox(QQuickItem *parent)
83 : QQuickAbstractButton(*(
new QQuickCheckBoxPrivate), parent)
89
90
91
92
93
94
95
96
97
98
99
100bool QQuickCheckBox::isTristate()
const
102 Q_D(
const QQuickCheckBox);
106void QQuickCheckBox::setTristate(
bool tristate)
109 if (d->tristate == tristate)
112 d->tristate = tristate;
113 emit tristateChanged();
117
118
119
120
121
122
123
124
125
126
127
128Qt::CheckState QQuickCheckBox::checkState()
const
130 Q_D(
const QQuickCheckBox);
131 return d->checkState;
134void QQuickCheckBox::setCheckState(Qt::CheckState state)
137 if (d->checkState == state)
140 bool wasChecked = isChecked();
141 d->checked = state == Qt::Checked;
142 d->checkState = state;
143 emit checkStateChanged();
144 if (d->checked != wasChecked)
145 emit checkedChanged();
148QJSValue QQuickCheckBox::getNextCheckState()
const
150 Q_D(
const QQuickCheckBox);
151 return d->nextCheckState;
154void QQuickCheckBox::setNextCheckState(
const QJSValue &callback)
157 d->nextCheckState = callback;
158 emit nextCheckStateChanged();
161QFont QQuickCheckBox::defaultFont()
const
163 return QQuickTheme::font(QQuickTheme::CheckBox);
166void QQuickCheckBox::buttonChange(ButtonChange change)
168 if (change == ButtonCheckedChange)
169 setCheckState(isChecked() ? Qt::Checked : Qt::Unchecked);
171 QQuickAbstractButton::buttonChange(change);
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
204
205
206
207void QQuickCheckBox::nextCheckState()
210 if (d->nextCheckState.isCallable())
211 setCheckState(
static_cast<Qt::CheckState>(d->nextCheckState.call().toInt()));
212 else if (d->tristate)
213 setCheckState(
static_cast<Qt::CheckState>((d->checkState + 1) % 3));
215 QQuickAbstractButton::nextCheckState();
220#include "moc_qquickcheckbox_p.cpp"
Check button that can be toggled on or off.
Qt::CheckState checkState
Combined button and popup list for selecting options.