1QCheckBox(3qt) QCheckBox(3qt)
2
3
4
6 QCheckBox - Checkbox with a text label
7
9 #include <qcheckbox.h>
10
11 Inherits QButton.
12
13 Public Members
14 QCheckBox ( QWidget * parent, const char * name = 0 )
15 QCheckBox ( const QString & text, QWidget * parent, const char * name =
16 0 )
17 bool isChecked () const
18 void setNoChange ()
19 void setTristate ( bool y = TRUE )
20 bool isTristate () const
21
22 Public Slots
23 void setChecked ( bool check )
24
25 Important Inherited Members
26 QString text () const
27 virtual void setText ( const QString & )
28 const QPixmap * pixmap () const
29 virtual void setPixmap ( const QPixmap & )
30 QKeySequence accel () const
31 virtual void setAccel ( const QKeySequence & )
32 bool isToggleButton () const
33 virtual void setDown ( bool )
34 bool isDown () const
35 bool isOn () const
36 ToggleState state () const
37 bool autoRepeat () const
38 virtual void setAutoRepeat ( bool )
39 bool isExclusiveToggle () const
40 QButtonGroup * group () const
41 void toggle ()
42 void pressed ()
43 void released ()
44 void clicked ()
45 void toggled ( bool on )
46 void stateChanged ( int state )
47
48 Properties
49 bool autoMask - whether the checkbox is automatically masked (read
50 only)
51 bool checked - whether the checkbox is checked
52 bool tristate - whether the checkbox is a tri-state checkbox
53
55 The QCheckBox widget provides a checkbox with a text label.
56
57 QCheckBox and QRadioButton are both option buttons. That is, they can
58 be switched on (checked) or off (unchecked). The classes differ in how
59 the choices for the user are restricted. Radio buttons define a "one of
60 many" choice, whereas checkboxes provide" many of many" choices.
61
62 A QButtonGroup can be used to group check buttons visually.
63
64 Whenever a checkbox is checked or cleared it emits the signal
65 toggled(). Connect to this signal if you want to trigger an action each
66 time the checkbox changes state. You can use isChecked() to query
67 whether or not a checkbox is checked.
68
69 Warning: The toggled() signal can not be trusted for tristate
70 checkboxes.
71
72 In addition to the usual checked and unchecked states, QCheckBox
73 optionally provides a third state to indicate "no change". This is
74 useful whenever you need to give the user the option of neither
75 checking nor unchecking a checkbox. If you need this third state,
76 enable it with setTristate() and use state() to query the current
77 toggle state. When a tristate checkbox changes state, it emits the
78 stateChanged() signal.
79
80 Just like QPushButton, a checkbox can display text or a pixmap. The
81 text can be set in the constructor or with setText(); the pixmap is set
82 with setPixmap().
83
84 [Image Omitted]
85
86 [Image Omitted]
87
88 See also QButton, QRadioButton, Fowler: Check Box, and Basic Widgets.
89
92 Constructs a checkbox with no text.
93
94 The parent and name arguments are sent to the QWidget constructor.
95
97 name = 0 )
98 Constructs a checkbox with text text.
99
100 The parent and name arguments are sent to the QWidget constructor.
101
103 Returns the accelerator associated with the button. See the "accel"
104 property for details.
105
107 Returns TRUE if autoRepeat is enabled; otherwise returns FALSE. See the
108 "autoRepeat" property for details.
109
111 This signal is emitted when the button is activated (i.e. first pressed
112 down and then released when the mouse cursor is inside the button),
113 when the accelerator key is typed or when animateClick() is called.
114 This signal is not emitted if you call setDown().
115
116 The QButtonGroup::clicked() signal does the same job, if you want to
117 connect several buttons to the same slot.
118
119 Warning: Don't launch a model dialog in response to this signal for a
120 button that has autoRepeat turned on.
121
122 See also pressed(), released(), toggled(), autoRepeat, and down.
123
124 Examples:
125
127 Returns the group that this button belongs to.
128
129 If the button is not a member of any QButtonGroup, this function
130 returns 0.
131
132 See also QButtonGroup.
133
135 Returns TRUE if the checkbox is checked; otherwise returns FALSE. See
136 the "checked" property for details.
137
139 Returns TRUE if the button is pressed; otherwise returns FALSE. See the
140 "down" property for details.
141
143 Returns TRUE if the button is an exclusive toggle; otherwise returns
144 FALSE. See the "exclusiveToggle" property for details.
145
147 Returns TRUE if the button is toggled; otherwise returns FALSE. See the
148 "on" property for details.
149
151 Returns TRUE if the button is a toggle button; otherwise returns FALSE.
152 See the "toggleButton" property for details.
153
155 Returns TRUE if the checkbox is a tri-state checkbox; otherwise returns
156 FALSE. See the "tristate" property for details.
157
159 Returns the pixmap shown on the button. See the "pixmap" property for
160 details.
161
163 This signal is emitted when the button is pressed down.
164
165 See also released() and clicked().
166
167 Examples:
168
170 This signal is emitted when the button is released.
171
172 See also pressed(), clicked(), and toggled().
173
175 Sets the accelerator associated with the button. See the "accel"
176 property for details.
177
179 Sets whether autoRepeat is enabled. See the "autoRepeat" property for
180 details.
181
183 Sets whether the checkbox is checked to check. See the "checked"
184 property for details.
185
187 Sets whether the button is pressed. See the "down" property for
188 details.
189
191 Sets the checkbox to the "no change" state.
192
193 See also tristate.
194
196 Sets the pixmap shown on the button. See the "pixmap" property for
197 details.
198
200 Sets the text shown on the button. See the "text" property for details.
201
203 Sets whether the checkbox is a tri-state checkbox to y. See the
204 "tristate" property for details.
205
207 Returns the state of the toggle button. See the "toggleState" property
208 for details.
209
211 This signal is emitted whenever a toggle button changes state. state is
212 On if the button is on, NoChange if it is in the" no change" state or
213 Off if the button is off.
214
215 This may be the result of a user action, toggle() slot activation,
216 setState(), or because setOn() was called.
217
218 See also clicked() and QButton::ToggleState.
219
221 Returns the text shown on the button. See the "text" property for
222 details.
223
225 Toggles the state of a toggle button.
226
227 See also on, setOn(), toggled(), and toggleButton.
228
230 This signal is emitted whenever a toggle button changes status. on is
231 TRUE if the button is on, or FALSE if the button is off.
232
233 This may be the result of a user action, toggle() slot activation, or
234 because setOn() was called.
235
236 See also clicked().
237
238 Example: listbox/listbox.cpp.
239
240 Property Documentation
242 This property holds the accelerator associated with the button.
243
244 This property is 0 if there is no accelerator set. If you set this
245 property to 0 then any current accelerator is removed.
246
247 Set this property's value with setAccel() and get this property's value
248 with accel().
249
251 This property holds whether the checkbox is automatically masked.
252
253 See also QWidget::autoMask.
254
256 This property holds whether autoRepeat is enabled.
257
258 If autoRepeat is enabled then the clicked() signal is emitted at
259 regular intervals if the button is down. This property has no effect on
260 toggle buttons. autoRepeat is off by default.
261
262 Set this property's value with setAutoRepeat() and get this property's
263 value with autoRepeat().
264
266 This property holds whether the checkbox is checked.
267
268 The default is unchecked, i.e. FALSE.
269
270 Set this property's value with setChecked() and get this property's
271 value with isChecked().
272
274 This property holds the pixmap shown on the button.
275
276 If the pixmap is monochrome (i.e. it is a QBitmap or its depth is 1)
277 and it does not have a mask, this property will set the pixmap to be
278 its own mask. The purpose of this is to draw transparent bitmaps which
279 are important for toggle buttons, for example.
280
281 pixmap() returns 0 if no pixmap was set.
282
283 Set this property's value with setPixmap() and get this property's
284 value with pixmap().
285
287 This property holds the text shown on the button.
288
289 This property will return a QString::null if the button has no text. If
290 the text has an ampersand (&) in it, then an accelerator is
291 automatically created for it using the character that follows the '&'
292 as the accelerator key. Any previous accelerator will be overwritten,
293 or cleared if no accelerator is defined by the text.
294
295 There is no default text.
296
297 Set this property's value with setText() and get this property's value
298 with text().
299
301 This property holds whether the checkbox is a tri-state checkbox.
302
303 The default is two-state, i.e. tri-state is FALSE.
304
305 Set this property's value with setTristate() and get this property's
306 value with isTristate().
307
308
310 http://doc.trolltech.com/qcheckbox.html
311 http://www.trolltech.com/faq/tech.html
312
314 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
315 license file included in the distribution for a complete license
316 statement.
317
319 Generated automatically from the source code.
320
322 If you find a bug in Qt, please report it as described in
323 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
324 help you. Thank you.
325
326 The definitive Qt documentation is provided in HTML format; it is
327 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
328 web browser. This man page is provided as a convenience for those users
329 who prefer man pages, although this format is not officially supported
330 by Trolltech.
331
332 If you find errors in this manual page, please report them to qt-
333 bugs@trolltech.com. Please include the name of the manual page
334 (qcheckbox.3qt) and the Qt version (3.3.8).
335
336
337
338Trolltech AS 2 February 2007 QCheckBox(3qt)