source: trunk/doc/html/qcheckbox.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 19.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qcheckbox.cpp:49 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QCheckBox Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCheckBox Class Reference</h1>
33
34<p>The QCheckBox widget provides a checkbox with a text label.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qcheckbox-h.html">qcheckbox.h</a>&gt;</tt>
37<p>Inherits <a href="qbutton.html">QButton</a>.
38<p><a href="qcheckbox-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QCheckBox"><b>QCheckBox</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
42<li class=fn><a href="#QCheckBox-2"><b>QCheckBox</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, QWidget&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn>bool <a href="#isChecked"><b>isChecked</b></a> () const</li>
44<li class=fn>void <a href="#setNoChange"><b>setNoChange</b></a> ()</li>
45<li class=fn>void <a href="#setTristate"><b>setTristate</b></a> ( bool&nbsp;y = TRUE )</li>
46<li class=fn>bool <a href="#isTristate"><b>isTristate</b></a> () const</li>
47</ul>
48<h2>Public Slots</h2>
49<ul>
50<li class=fn>void <a href="#setChecked"><b>setChecked</b></a> ( bool&nbsp;check )</li>
51</ul>
52<h2>Important Inherited Members</h2>
53<ul>
54<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
55<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString &amp; )</li>
56<li class=fn>const QPixmap * <a href="#pixmap"><b>pixmap</b></a> () const</li>
57<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const QPixmap &amp; )</li>
58<li class=fn>QKeySequence <a href="#accel"><b>accel</b></a> () const</li>
59<li class=fn>virtual void <a href="#setAccel"><b>setAccel</b></a> ( const QKeySequence &amp; )</li>
60<li class=fn>bool <a href="#isToggleButton"><b>isToggleButton</b></a> () const</li>
61<li class=fn>virtual void <a href="#setDown"><b>setDown</b></a> ( bool )</li>
62<li class=fn>bool <a href="#isDown"><b>isDown</b></a> () const</li>
63<li class=fn>bool <a href="#isOn"><b>isOn</b></a> () const</li>
64<li class=fn>ToggleState <a href="#state"><b>state</b></a> () const</li>
65<li class=fn>bool <a href="#autoRepeat"><b>autoRepeat</b></a> () const</li>
66<li class=fn>virtual void <a href="#setAutoRepeat"><b>setAutoRepeat</b></a> ( bool )</li>
67<li class=fn>bool <a href="#isExclusiveToggle"><b>isExclusiveToggle</b></a> () const</li>
68<li class=fn>QButtonGroup * <a href="#group"><b>group</b></a> () const</li>
69<li class=fn>void <a href="#toggle"><b>toggle</b></a> ()</li>
70<li class=fn>void <a href="#pressed"><b>pressed</b></a> ()</li>
71<li class=fn>void <a href="#released"><b>released</b></a> ()</li>
72<li class=fn>void <a href="#clicked"><b>clicked</b></a> ()</li>
73<li class=fn>void <a href="#toggled"><b>toggled</b></a> ( bool&nbsp;on )</li>
74<li class=fn>void <a href="#stateChanged"><b>stateChanged</b></a> ( int&nbsp;state )</li>
75</ul>
76<h2>Properties</h2>
77<ul>
78<li class=fn>bool <a href="#autoMask-prop"><b>autoMask</b></a>&nbsp;- whether the checkbox is automatically masked &nbsp;<em>(read only)</em></li>
79<li class=fn>bool <a href="#checked-prop"><b>checked</b></a>&nbsp;- whether the checkbox is checked</li>
80<li class=fn>bool <a href="#tristate-prop"><b>tristate</b></a>&nbsp;- whether the checkbox is a tri-state checkbox</li>
81</ul>
82<hr><a name="details"></a><h2>Detailed Description</h2>
83
84
85The QCheckBox widget provides a checkbox with a text label.
86<p>
87
88<p> QCheckBox and <a href="qradiobutton.html">QRadioButton</a> are both option buttons. That is, they
89can be switched on (checked) or off (unchecked). The classes
90differ in how the choices for the user are restricted. Radio
91buttons define a "one of many" choice, whereas checkboxes provide
92"many of many" choices.
93<p> A <a href="qbuttongroup.html">QButtonGroup</a> can be used to group check buttons visually.
94<p> Whenever a checkbox is checked or cleared it emits the signal
95<a href="qbutton.html#toggled">toggled</a>(). Connect to this signal if you want to trigger an action
96each time the checkbox changes state. You can use <a href="#isChecked">isChecked</a>() to
97query whether or not a checkbox is checked.
98<p> <b>Warning:</b> The toggled() signal can not be trusted for tristate
99checkboxes.
100<p> In addition to the usual checked and unchecked states, QCheckBox
101optionally provides a third state to indicate "no change". This
102is useful whenever you need to give the user the option of neither
103checking nor unchecking a checkbox. If you need this third state,
104enable it with <a href="#setTristate">setTristate</a>() and use <a href="qbutton.html#state">state</a>() to query the current
105toggle state. When a tristate checkbox changes state, it emits the
106<a href="qbutton.html#stateChanged">stateChanged</a>() signal.
107<p> Just like <a href="qpushbutton.html">QPushButton</a>, a checkbox can display text or a pixmap.
108The text can be set in the constructor or with <a href="qbutton.html#setText">setText</a>(); the
109pixmap is set with <a href="qbutton.html#setPixmap">setPixmap</a>().
110<p>
111<p> <img src=qchkbox-m.png> <img src=qchkbox-w.png>
112<p> <p>See also <a href="qbutton.html">QButton</a>, <a href="qradiobutton.html">QRadioButton</a>, <a href="guibooks.html#fowler">Fowler: Check Box</a>, and <a href="basic.html">Basic Widgets</a>.
113
114<hr><h2>Member Function Documentation</h2>
115<h3 class=fn><a name="QCheckBox"></a>QCheckBox::QCheckBox ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
116</h3>
117Constructs a checkbox with no text.
118<p> The <em>parent</em> and <em>name</em> arguments are sent to the <a href="qwidget.html">QWidget</a>
119constructor.
120
121<h3 class=fn><a name="QCheckBox-2"></a>QCheckBox::QCheckBox ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
122</h3>
123Constructs a checkbox with text <em>text</em>.
124<p> The <em>parent</em> and <em>name</em> arguments are sent to the <a href="qwidget.html">QWidget</a>
125constructor.
126
127<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QButton::accel () const
128</h3><p>Returns the accelerator associated with the button.
129See the <a href="qbutton.html#accel-prop">"accel"</a> property for details.
130<h3 class=fn>bool <a name="autoRepeat"></a>QButton::autoRepeat () const
131</h3><p>Returns TRUE if autoRepeat is enabled; otherwise returns FALSE.
132See the <a href="qbutton.html#autoRepeat-prop">"autoRepeat"</a> property for details.
133<h3 class=fn>void <a name="clicked"></a>QButton::clicked ()<tt> [signal]</tt>
134</h3>
135
136<p> This signal is emitted when the button is activated (i.e. first
137pressed down and then released when the mouse cursor is inside the
138button), when the accelerator key is typed or when <a href="qbutton.html#animateClick">animateClick</a>()
139is called. This signal is <em>not</em> emitted if you call <a href="qbutton.html#setDown">setDown</a>().
140<p> The <a href="qbuttongroup.html#clicked">QButtonGroup::clicked</a>() signal does the same job, if you want
141to connect several buttons to the same slot.
142<p> <b>Warning:</b> Don't launch a model dialog in response to this signal
143for a button that has <a href="qbutton.html#autoRepeat-prop">autoRepeat</a> turned on.
144<p> <p>See also <a href="qbutton.html#pressed">pressed</a>(), <a href="qbutton.html#released">released</a>(), <a href="qbutton.html#toggled">toggled</a>(), <a href="qbutton.html#autoRepeat-prop">autoRepeat</a>, and <a href="qbutton.html#down-prop">down</a>.
145
146<p>Examples: <a href="tutorial2-08.html#x2596">chart/setdataform.cpp</a>, <a href="listbox-example.html#x1426">listbox/listbox.cpp</a>, <a href="clientserver-example.html#x792">network/clientserver/client/client.cpp</a>, <a href="progressbar-example.html#x962">progressbar/progressbar.cpp</a>, <a href="richtext-example.html#x462">richtext/richtext.cpp</a>, <a href="tutorial1-02.html#x2290">t2/main.cpp</a>, and <a href="tutorial1-04.html#x2306">t4/main.cpp</a>.
147<h3 class=fn><a href="qbuttongroup.html">QButtonGroup</a>&nbsp;* <a name="group"></a>QButton::group () const
148</h3>
149Returns the group that this button belongs to.
150<p> If the button is not a member of any <a href="qbuttongroup.html">QButtonGroup</a>, this function
151returns 0.
152<p> <p>See also <a href="qbuttongroup.html">QButtonGroup</a>.
153
154<h3 class=fn>bool <a name="isChecked"></a>QCheckBox::isChecked () const
155</h3><p>Returns TRUE if the checkbox is checked; otherwise returns FALSE.
156See the <a href="qcheckbox.html#checked-prop">"checked"</a> property for details.
157<h3 class=fn>bool <a name="isDown"></a>QButton::isDown () const
158</h3><p>Returns TRUE if the button is pressed; otherwise returns FALSE.
159See the <a href="qbutton.html#down-prop">"down"</a> property for details.
160<h3 class=fn>bool <a name="isExclusiveToggle"></a>QButton::isExclusiveToggle () const
161</h3><p>Returns TRUE if the button is an exclusive toggle; otherwise returns FALSE.
162See the <a href="qbutton.html#exclusiveToggle-prop">"exclusiveToggle"</a> property for details.
163<h3 class=fn>bool <a name="isOn"></a>QButton::isOn () const
164</h3><p>Returns TRUE if the button is toggled; otherwise returns FALSE.
165See the <a href="qbutton.html#on-prop">"on"</a> property for details.
166<h3 class=fn>bool <a name="isToggleButton"></a>QButton::isToggleButton () const
167</h3><p>Returns TRUE if the button is a toggle button; otherwise returns FALSE.
168See the <a href="qbutton.html#toggleButton-prop">"toggleButton"</a> property for details.
169<h3 class=fn>bool <a name="isTristate"></a>QCheckBox::isTristate () const
170</h3><p>Returns TRUE if the checkbox is a tri-state checkbox; otherwise returns FALSE.
171See the <a href="qcheckbox.html#tristate-prop">"tristate"</a> property for details.
172<h3 class=fn>const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="pixmap"></a>QButton::pixmap () const
173</h3><p>Returns the pixmap shown on the button.
174See the <a href="qbutton.html#pixmap-prop">"pixmap"</a> property for details.
175<h3 class=fn>void <a name="pressed"></a>QButton::pressed ()<tt> [signal]</tt>
176</h3>
177
178<p> This signal is emitted when the button is pressed down.
179<p> <p>See also <a href="qbutton.html#released">released</a>() and <a href="qbutton.html#clicked">clicked</a>().
180
181<p>Examples: <a href="httpd-example.html#x724">network/httpd/httpd.cpp</a> and <a href="popup-example.html#x1606">popup/popup.cpp</a>.
182<h3 class=fn>void <a name="released"></a>QButton::released ()<tt> [signal]</tt>
183</h3>
184
185<p> This signal is emitted when the button is released.
186<p> <p>See also <a href="qbutton.html#pressed">pressed</a>(), <a href="qbutton.html#clicked">clicked</a>(), and <a href="qbutton.html#toggled">toggled</a>().
187
188<h3 class=fn>void <a name="setAccel"></a>QButton::setAccel ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp; )<tt> [virtual]</tt>
189</h3><p>Sets the accelerator associated with the button.
190See the <a href="qbutton.html#accel-prop">"accel"</a> property for details.
191<h3 class=fn>void <a name="setAutoRepeat"></a>QButton::setAutoRepeat ( bool )<tt> [virtual]</tt>
192</h3><p>Sets whether autoRepeat is enabled.
193See the <a href="qbutton.html#autoRepeat-prop">"autoRepeat"</a> property for details.
194<h3 class=fn>void <a name="setChecked"></a>QCheckBox::setChecked ( bool&nbsp;check )<tt> [slot]</tt>
195</h3><p>Sets whether the checkbox is checked to <em>check</em>.
196See the <a href="qcheckbox.html#checked-prop">"checked"</a> property for details.
197<h3 class=fn>void <a name="setDown"></a>QButton::setDown ( bool )<tt> [virtual]</tt>
198</h3><p>Sets whether the button is pressed.
199See the <a href="qbutton.html#down-prop">"down"</a> property for details.
200<h3 class=fn>void <a name="setNoChange"></a>QCheckBox::setNoChange ()
201</h3>
202Sets the checkbox to the "no change" state.
203<p> <p>See also <a href="#tristate-prop">tristate</a>.
204
205<h3 class=fn>void <a name="setPixmap"></a>QButton::setPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp; )<tt> [virtual]</tt>
206</h3><p>Sets the pixmap shown on the button.
207See the <a href="qbutton.html#pixmap-prop">"pixmap"</a> property for details.
208<h3 class=fn>void <a name="setText"></a>QButton::setText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
209</h3><p>Sets the text shown on the button.
210See the <a href="qbutton.html#text-prop">"text"</a> property for details.
211<h3 class=fn>void <a name="setTristate"></a>QCheckBox::setTristate ( bool&nbsp;y = TRUE )
212</h3><p>Sets whether the checkbox is a tri-state checkbox to <em>y</em>.
213See the <a href="qcheckbox.html#tristate-prop">"tristate"</a> property for details.
214<h3 class=fn><a href="qbutton.html#ToggleState-enum">ToggleState</a> <a name="state"></a>QButton::state () const
215</h3><p>Returns the state of the toggle button.
216See the <a href="qbutton.html#toggleState-prop">"toggleState"</a> property for details.
217<h3 class=fn>void <a name="stateChanged"></a>QButton::stateChanged ( int&nbsp;state )<tt> [signal]</tt>
218</h3>
219
220<p> This signal is emitted whenever a toggle button changes state. <em>state</em> is <a href="qbutton.html#ToggleState-enum">On</a> if the button is on, <a href="qbutton.html#ToggleState-enum">NoChange</a> if it is in the
221<a href="#setTristate">"no change" state</a> or <a href="qbutton.html#ToggleState-enum">Off</a>
222if the button is off.
223<p> This may be the result of a user action, <a href="qbutton.html#toggle">toggle</a>() slot activation,
224<a href="qbutton.html#setState">setState</a>(), or because <a href="qbutton.html#setOn">setOn</a>() was called.
225<p> <p>See also <a href="qbutton.html#clicked">clicked</a>() and <a href="qbutton.html#ToggleState-enum">QButton::ToggleState</a>.
226
227<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QButton::text () const
228</h3><p>Returns the text shown on the button.
229See the <a href="qbutton.html#text-prop">"text"</a> property for details.
230<h3 class=fn>void <a name="toggle"></a>QButton::toggle ()<tt> [slot]</tt>
231</h3>
232Toggles the state of a toggle button.
233<p> <p>See also <a href="qbutton.html#on-prop">on</a>, <a href="qbutton.html#setOn">setOn</a>(), <a href="qbutton.html#toggled">toggled</a>(), and <a href="qbutton.html#toggleButton-prop">toggleButton</a>.
234
235<h3 class=fn>void <a name="toggled"></a>QButton::toggled ( bool&nbsp;on )<tt> [signal]</tt>
236</h3>
237
238<p> This signal is emitted whenever a toggle button changes status. <em>on</em> is TRUE if the button is on, or FALSE if the button is off.
239<p> This may be the result of a user action, <a href="qbutton.html#toggle">toggle</a>() slot activation,
240or because <a href="qbutton.html#setOn">setOn</a>() was called.
241<p> <p>See also <a href="qbutton.html#clicked">clicked</a>().
242
243<p>Example: <a href="listbox-example.html#x1427">listbox/listbox.cpp</a>.
244<hr><h2>Property Documentation</h2>
245<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel-prop"></a>accel</h3>
246<p>This property holds the accelerator associated with the button.
247<p>This property is 0 if there is no accelerator set. If you set this
248property to 0 then any current accelerator is removed.
249
250<p>Set this property's value with <a href="#setAccel">setAccel</a>() and get this property's value with <a href="#accel">accel</a>().
251<h3 class=fn>bool <a name="autoMask-prop"></a>autoMask</h3>
252<p>This property holds whether the checkbox is automatically masked.
253<p><p><p>See also <a href="qwidget.html#autoMask-prop">QWidget::autoMask</a>.
254
255<h3 class=fn>bool <a name="autoRepeat-prop"></a>autoRepeat</h3>
256<p>This property holds whether autoRepeat is enabled.
257<p>If autoRepeat is enabled then the <a href="qbutton.html#clicked">clicked</a>() signal is emitted at
258regular intervals if the button is down. This property has no
259effect on toggle buttons. autoRepeat is off by default.
260
261<p>Set this property's value with <a href="#setAutoRepeat">setAutoRepeat</a>() and get this property's value with <a href="#autoRepeat">autoRepeat</a>().
262<h3 class=fn>bool <a name="checked-prop"></a>checked</h3>
263<p>This property holds whether the checkbox is checked.
264<p>The default is unchecked, i.e. FALSE.
265
266<p>Set this property's value with <a href="#setChecked">setChecked</a>() and get this property's value with <a href="#isChecked">isChecked</a>().
267<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-prop"></a>pixmap</h3>
268<p>This property holds the pixmap shown on the button.
269<p>If the pixmap is monochrome (i.e. it is a <a href="qbitmap.html">QBitmap</a> or its <a href="qpixmap.html#depth">depth</a> is 1) and it does not have a mask,
270this property will set the pixmap to be its own mask. The purpose
271of this is to draw transparent bitmaps which are important for
272toggle buttons, for example.
273<p> <a href="qbutton.html#pixmap">pixmap</a>() returns 0 if no pixmap was set.
274
275<p>Set this property's value with <a href="#setPixmap">setPixmap</a>() and get this property's value with <a href="#pixmap">pixmap</a>().
276<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
277<p>This property holds the text shown on the button.
278<p>This property will return a <a href="qstring.html#QString-null">QString::null</a> if the button has no
279text. If the text has an ampersand (&amp;) in it, then an
280accelerator is automatically created for it using the character
281that follows the '&amp;' as the accelerator key. Any previous
282accelerator will be overwritten, or cleared if no accelerator is
283defined by the text.
284<p> There is no default text.
285
286<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
287<h3 class=fn>bool <a name="tristate-prop"></a>tristate</h3>
288<p>This property holds whether the checkbox is a tri-state checkbox.
289<p>The default is two-state, i.e. tri-state is FALSE.
290
291<p>Set this property's value with <a href="#setTristate">setTristate</a>() and get this property's value with <a href="#isTristate">isTristate</a>().
292<!-- eof -->
293<hr><p>
294This file is part of the <a href="index.html">Qt toolkit</a>.
295Copyright &copy; 1995-2007
296<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
297<table width=100% cellspacing=0 border=0><tr>
298<td>Copyright &copy; 2007
299<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
300<td align=right><div align=right>Qt 3.3.8</div>
301</table></div></address></body>
302</html>
Note: See TracBrowser for help on using the repository browser.