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

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

reference documentation added

File size: 30.4 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/qpushbutton.cpp:55 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QPushButton 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>QPushButton Class Reference</h1>
33
34<p>The QPushButton widget provides a command button.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;</tt>
37<p>Inherits <a href="qbutton.html">QButton</a>.
38<p><a href="qpushbutton-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QPushButton"><b>QPushButton</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
42<li class=fn><a href="#QPushButton-2"><b>QPushButton</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><a href="#QPushButton-3"><b>QPushButton</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;text, QWidget&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
44<li class=fn><a href="#~QPushButton"><b>~QPushButton</b></a> ()</li>
45<li class=fn>void <a href="#setToggleButton"><b>setToggleButton</b></a> ( bool )</li>
46<li class=fn>bool <a href="#autoDefault"><b>autoDefault</b></a> () const</li>
47<li class=fn>virtual void <a href="#setAutoDefault"><b>setAutoDefault</b></a> ( bool&nbsp;autoDef )</li>
48<li class=fn>bool <a href="#isDefault"><b>isDefault</b></a> () const</li>
49<li class=fn>virtual void <a href="#setDefault"><b>setDefault</b></a> ( bool&nbsp;def )</li>
50<li class=fn>virtual void setIsMenuButton ( bool&nbsp;enable ) &nbsp;<em>(obsolete)</em></li>
51<li class=fn>bool isMenuButton () const &nbsp;<em>(obsolete)</em></li>
52<li class=fn>void <a href="#setPopup"><b>setPopup</b></a> ( QPopupMenu&nbsp;*&nbsp;popup )</li>
53<li class=fn>QPopupMenu * <a href="#popup"><b>popup</b></a> () const</li>
54<li class=fn>void <a href="#setIconSet"><b>setIconSet</b></a> ( const QIconSet &amp; )</li>
55<li class=fn>QIconSet * <a href="#iconSet"><b>iconSet</b></a> () const</li>
56<li class=fn>void <a href="#setFlat"><b>setFlat</b></a> ( bool )</li>
57<li class=fn>bool <a href="#isFlat"><b>isFlat</b></a> () const</li>
58</ul>
59<h2>Public Slots</h2>
60<ul>
61<li class=fn>virtual void <a href="#setOn"><b>setOn</b></a> ( bool )</li>
62</ul>
63<h2>Important Inherited Members</h2>
64<ul>
65<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
66<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString &amp; )</li>
67<li class=fn>const QPixmap * <a href="#pixmap"><b>pixmap</b></a> () const</li>
68<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const QPixmap &amp; )</li>
69<li class=fn>QKeySequence <a href="#accel"><b>accel</b></a> () const</li>
70<li class=fn>virtual void <a href="#setAccel"><b>setAccel</b></a> ( const QKeySequence &amp; )</li>
71<li class=fn>bool <a href="#isToggleButton"><b>isToggleButton</b></a> () const</li>
72<li class=fn>virtual void <a href="#setDown"><b>setDown</b></a> ( bool )</li>
73<li class=fn>bool <a href="#isDown"><b>isDown</b></a> () const</li>
74<li class=fn>bool <a href="#isOn"><b>isOn</b></a> () const</li>
75<li class=fn>ToggleState <a href="#state"><b>state</b></a> () const</li>
76<li class=fn>bool <a href="#autoRepeat"><b>autoRepeat</b></a> () const</li>
77<li class=fn>virtual void <a href="#setAutoRepeat"><b>setAutoRepeat</b></a> ( bool )</li>
78<li class=fn>bool <a href="#isExclusiveToggle"><b>isExclusiveToggle</b></a> () const</li>
79<li class=fn>QButtonGroup * <a href="#group"><b>group</b></a> () const</li>
80<li class=fn>void <a href="#toggle"><b>toggle</b></a> ()</li>
81<li class=fn>void <a href="#pressed"><b>pressed</b></a> ()</li>
82<li class=fn>void <a href="#released"><b>released</b></a> ()</li>
83<li class=fn>void <a href="#clicked"><b>clicked</b></a> ()</li>
84<li class=fn>void <a href="#toggled"><b>toggled</b></a> ( bool&nbsp;on )</li>
85<li class=fn>void <a href="#stateChanged"><b>stateChanged</b></a> ( int&nbsp;state )</li>
86</ul>
87<h2>Properties</h2>
88<ul>
89<li class=fn>bool <a href="#autoDefault-prop"><b>autoDefault</b></a>&nbsp;- whether the push button is the auto default button</li>
90<li class=fn>bool <a href="#autoMask-prop"><b>autoMask</b></a>&nbsp;- whether the button is automatically masked &nbsp;<em>(read only)</em></li>
91<li class=fn>bool <a href="#default-prop"><b>default</b></a>&nbsp;- whether the push button is the default button</li>
92<li class=fn>bool <a href="#flat-prop"><b>flat</b></a>&nbsp;- whether the border is disabled</li>
93<li class=fn>QIconSet <a href="#iconSet-prop"><b>iconSet</b></a>&nbsp;- the icon set on the push button</li>
94<li class=fn>bool menuButton&nbsp;- whether the push button has a menu button on it &nbsp;<em>(read only)</em> &nbsp;<em>(obsolete)</em></li>
95<li class=fn>bool <a href="#on-prop"><b>on</b></a>&nbsp;- whether the push button is toggled</li>
96<li class=fn>bool <a href="#toggleButton-prop"><b>toggleButton</b></a>&nbsp;- whether the button is a toggle button</li>
97</ul>
98<hr><a name="details"></a><h2>Detailed Description</h2>
99
100
101The QPushButton widget provides a command button.
102<p>
103
104<p> The push button, or command button, is perhaps the most commonly
105used widget in any graphical user interface. Push (click) a button
106to command the computer to perform some action, or to answer a
107question. Typical buttons are OK, Apply, Cancel, Close, Yes, No
108and Help.
109<p> A command button is rectangular and typically displays a text
110label describing its action. An underlined character in the label
111(signified by preceding it with an ampersand in the text)
112indicates an accelerator key, e.g.
113<pre>
114 QPushButton *pb = new QPushButton( "&amp;Download", this );
115 </pre>
116
117In this example the accelerator is <em>Alt+D</em>, and the label text
118will be displayed as <b><u>D</u>ownload</b>.
119<p> Push buttons can display a textual label or a pixmap, and
120optionally a small icon. These can be set using the constructors
121and changed later using <a href="qbutton.html#setText">setText</a>(), <a href="qbutton.html#setPixmap">setPixmap</a>() and <a href="#setIconSet">setIconSet</a>().
122If the button is disabled the appearance of the text or pixmap and
123iconset will be manipulated with respect to the GUI style to make
124the button look "disabled".
125<p> A push button emits the signal <a href="qbutton.html#clicked">clicked</a>() when it is activated by
126the mouse, the Spacebar or by a keyboard accelerator. Connect to
127this signal to perform the button's action. Push buttons also
128provide less commonly used signals, for example, <a href="qbutton.html#pressed">pressed</a>() and
129<a href="qbutton.html#released">released</a>().
130<p> Command buttons in dialogs are by default auto-default buttons,
131i.e. they become the default push button automatically when they
132receive the keyboard input focus. A default button is a push
133button that is activated when the user presses the Enter or Return
134key in a dialog. You can change this with <a href="#setAutoDefault">setAutoDefault</a>(). Note
135that auto-default buttons reserve a little extra space which is
136necessary to draw a default-button indicator. If you do not want
137this space around your buttons, call setAutoDefault(FALSE).
138<p> Being so central, the button widget has grown to accommodate a
139great many variations in the past decade. The Microsoft style
140guide now shows about ten different states of Windows push buttons
141and the text implies that there are dozens more when all the
142combinations of features are taken into consideration.
143<p> The most important modes or states are:
144<ul>
145<li> Available or not (grayed out, disabled).
146<li> Standard push button, toggling push button or menu button.
147<li> On or off (only for toggling push buttons).
148<li> Default or normal. The default button in a dialog can generally
149be "clicked" using the Enter or Return key.
150<li> Auto-repeat or not.
151<li> Pressed down or not.
152</ul>
153<p> As a general rule, use a push button when the application or
154dialog window performs an action when the user clicks on it (such
155as Apply, Cancel, Close and Help) <em>and</em> when the widget is
156supposed to have a wide, rectangular shape with a text label.
157Small, typically square buttons that change the state of the
158window rather than performing an action (such as the buttons in
159the top-right corner of the <a href="qfiledialog.html">QFileDialog</a>) are not command buttons,
160but tool buttons. Qt provides a special class (<a href="qtoolbutton.html">QToolButton</a>) for
161these buttons.
162<p> If you need toggle behavior (see <a href="#setToggleButton">setToggleButton</a>()) or a button
163that auto-repeats the activation signal when being pushed down
164like the arrows in a scroll bar (see <a href="qbutton.html#setAutoRepeat">setAutoRepeat</a>()), a command
165button is probably not what you want. When in doubt, use a tool
166button.
167<p> A variation of a command button is a menu button. These provide
168not just one command, but several, since when they are clicked
169they pop up a menu of options. Use the method <a href="#setPopup">setPopup</a>() to
170associate a popup menu with a push button.
171<p> Other classes of buttons are option buttons (see <a href="qradiobutton.html">QRadioButton</a>) and
172check boxes (see <a href="qcheckbox.html">QCheckBox</a>).
173<p> <img src="qpushbt-m.png"> <img src="qpushbt-w.png">
174<p> In Qt, the <a href="qbutton.html">QButton</a> abstract base class provides most of the modes
175and other API, and QPushButton provides GUI logic. See QButton for
176more information about the API.
177<p>
178<p> <p>See also <a href="qtoolbutton.html">QToolButton</a>, <a href="qradiobutton.html">QRadioButton</a>, <a href="qcheckbox.html">QCheckBox</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Push Button</a>, and <a href="basic.html">Basic Widgets</a>.
179
180<hr><h2>Member Function Documentation</h2>
181<h3 class=fn><a name="QPushButton"></a>QPushButton::QPushButton ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
182</h3>
183Constructs a push button with no text.
184<p> The <em>parent</em> and <em>name</em> arguments are sent on to the <a href="qwidget.html">QWidget</a>
185constructor.
186
187<h3 class=fn><a name="QPushButton-2"></a>QPushButton::QPushButton ( 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 )
188</h3>
189Constructs a push button called <em>name</em> with the parent <em>parent</em>
190and the text <em>text</em>.
191
192<h3 class=fn><a name="QPushButton-3"></a>QPushButton::QPushButton ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, 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 )
193</h3>
194Constructs a push button with an <em>icon</em> and a <em>text</em>.
195<p> Note that you can also pass a <a href="qpixmap.html">QPixmap</a> object as an icon (thanks to
196the implicit type conversion provided by C++).
197<p> The <em>parent</em> and <em>name</em> arguments are sent to the <a href="qwidget.html">QWidget</a>
198constructor.
199
200<h3 class=fn><a name="~QPushButton"></a>QPushButton::~QPushButton ()
201</h3>
202Destroys the push button.
203
204<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QButton::accel () const
205</h3><p>Returns the accelerator associated with the button.
206See the <a href="qbutton.html#accel-prop">"accel"</a> property for details.
207<h3 class=fn>bool <a name="autoDefault"></a>QPushButton::autoDefault () const
208</h3><p>Returns TRUE if the push button is the auto default button; otherwise returns FALSE.
209See the <a href="qpushbutton.html#autoDefault-prop">"autoDefault"</a> property for details.
210<h3 class=fn>bool <a name="autoRepeat"></a>QButton::autoRepeat () const
211</h3><p>Returns TRUE if autoRepeat is enabled; otherwise returns FALSE.
212See the <a href="qbutton.html#autoRepeat-prop">"autoRepeat"</a> property for details.
213<h3 class=fn>void <a name="clicked"></a>QButton::clicked ()<tt> [signal]</tt>
214</h3>
215
216<p> This signal is emitted when the button is activated (i.e. first
217pressed down and then released when the mouse cursor is inside the
218button), when the accelerator key is typed or when <a href="qbutton.html#animateClick">animateClick</a>()
219is called. This signal is <em>not</em> emitted if you call <a href="qbutton.html#setDown">setDown</a>().
220<p> The <a href="qbuttongroup.html#clicked">QButtonGroup::clicked</a>() signal does the same job, if you want
221to connect several buttons to the same slot.
222<p> <b>Warning:</b> Don't launch a model dialog in response to this signal
223for a button that has <a href="qbutton.html#autoRepeat-prop">autoRepeat</a> turned on.
224<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>.
225
226<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>.
227<h3 class=fn><a href="qbuttongroup.html">QButtonGroup</a>&nbsp;* <a name="group"></a>QButton::group () const
228</h3>
229Returns the group that this button belongs to.
230<p> If the button is not a member of any <a href="qbuttongroup.html">QButtonGroup</a>, this function
231returns 0.
232<p> <p>See also <a href="qbuttongroup.html">QButtonGroup</a>.
233
234<h3 class=fn><a href="qiconset.html">QIconSet</a>&nbsp;* <a name="iconSet"></a>QPushButton::iconSet () const
235</h3><p>Returns the icon set on the push button.
236See the <a href="qpushbutton.html#iconSet-prop">"iconSet"</a> property for details.
237<h3 class=fn>bool <a name="isDefault"></a>QPushButton::isDefault () const
238</h3><p>Returns TRUE if the push button is the default button; otherwise returns FALSE.
239See the <a href="qpushbutton.html#default-prop">"default"</a> property for details.
240<h3 class=fn>bool <a name="isDown"></a>QButton::isDown () const
241</h3><p>Returns TRUE if the button is pressed; otherwise returns FALSE.
242See the <a href="qbutton.html#down-prop">"down"</a> property for details.
243<h3 class=fn>bool <a name="isExclusiveToggle"></a>QButton::isExclusiveToggle () const
244</h3><p>Returns TRUE if the button is an exclusive toggle; otherwise returns FALSE.
245See the <a href="qbutton.html#exclusiveToggle-prop">"exclusiveToggle"</a> property for details.
246<h3 class=fn>bool <a name="isFlat"></a>QPushButton::isFlat () const
247</h3><p>Returns TRUE if the border is disabled; otherwise returns FALSE.
248See the <a href="qpushbutton.html#flat-prop">"flat"</a> property for details.
249<h3 class=fn>bool <a name="isMenuButton"></a>QPushButton::isMenuButton () const
250</h3><p>Returns TRUE if the push button has a menu button on it; otherwise returns FALSE.
251See the <a href="qpushbutton.html#menuButton-prop">"menuButton"</a> property for details.
252<h3 class=fn>bool <a name="isOn"></a>QButton::isOn () const
253</h3><p>Returns TRUE if the button is toggled; otherwise returns FALSE.
254See the <a href="qbutton.html#on-prop">"on"</a> property for details.
255<h3 class=fn>bool <a name="isToggleButton"></a>QButton::isToggleButton () const
256</h3><p>Returns TRUE if the button is a toggle button; otherwise returns FALSE.
257See the <a href="qbutton.html#toggleButton-prop">"toggleButton"</a> property for details.
258<h3 class=fn>const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="pixmap"></a>QButton::pixmap () const
259</h3><p>Returns the pixmap shown on the button.
260See the <a href="qbutton.html#pixmap-prop">"pixmap"</a> property for details.
261<h3 class=fn><a href="qpopupmenu.html">QPopupMenu</a>&nbsp;* <a name="popup"></a>QPushButton::popup () const
262</h3>
263Returns the button's associated popup menu or 0 if no popup menu
264has been set.
265<p> <p>See also <a href="#setPopup">setPopup</a>().
266
267<h3 class=fn>void <a name="pressed"></a>QButton::pressed ()<tt> [signal]</tt>
268</h3>
269
270<p> This signal is emitted when the button is pressed down.
271<p> <p>See also <a href="qbutton.html#released">released</a>() and <a href="qbutton.html#clicked">clicked</a>().
272
273<p>Examples: <a href="httpd-example.html#x724">network/httpd/httpd.cpp</a> and <a href="popup-example.html#x1606">popup/popup.cpp</a>.
274<h3 class=fn>void <a name="released"></a>QButton::released ()<tt> [signal]</tt>
275</h3>
276
277<p> This signal is emitted when the button is released.
278<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>().
279
280<h3 class=fn>void <a name="setAccel"></a>QButton::setAccel ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp; )<tt> [virtual]</tt>
281</h3><p>Sets the accelerator associated with the button.
282See the <a href="qbutton.html#accel-prop">"accel"</a> property for details.
283<h3 class=fn>void <a name="setAutoDefault"></a>QPushButton::setAutoDefault ( bool&nbsp;autoDef )<tt> [virtual]</tt>
284</h3><p>Sets whether the push button is the auto default button to <em>autoDef</em>.
285See the <a href="qpushbutton.html#autoDefault-prop">"autoDefault"</a> property for details.
286<h3 class=fn>void <a name="setAutoRepeat"></a>QButton::setAutoRepeat ( bool )<tt> [virtual]</tt>
287</h3><p>Sets whether autoRepeat is enabled.
288See the <a href="qbutton.html#autoRepeat-prop">"autoRepeat"</a> property for details.
289<h3 class=fn>void <a name="setDefault"></a>QPushButton::setDefault ( bool&nbsp;def )<tt> [virtual]</tt>
290</h3><p>Sets whether the push button is the default button to <em>def</em>.
291See the <a href="qpushbutton.html#default-prop">"default"</a> property for details.
292<h3 class=fn>void <a name="setDown"></a>QButton::setDown ( bool )<tt> [virtual]</tt>
293</h3><p>Sets whether the button is pressed.
294See the <a href="qbutton.html#down-prop">"down"</a> property for details.
295<h3 class=fn>void <a name="setFlat"></a>QPushButton::setFlat ( bool )
296</h3><p>Sets whether the border is disabled.
297See the <a href="qpushbutton.html#flat-prop">"flat"</a> property for details.
298<h3 class=fn>void <a name="setIconSet"></a>QPushButton::setIconSet ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp; )
299</h3><p>Sets the icon set on the push button.
300See the <a href="qpushbutton.html#iconSet-prop">"iconSet"</a> property for details.
301<h3 class=fn>void <a name="setIsMenuButton"></a>QPushButton::setIsMenuButton ( bool&nbsp;enable )<tt> [virtual]</tt>
302</h3>
303<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
304<p>
305
306<h3 class=fn>void <a name="setOn"></a>QPushButton::setOn ( bool )<tt> [virtual slot]</tt>
307</h3><p>Sets whether the push button is toggled.
308See the <a href="qpushbutton.html#on-prop">"on"</a> property for details.
309<h3 class=fn>void <a name="setPixmap"></a>QButton::setPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp; )<tt> [virtual]</tt>
310</h3><p>Sets the pixmap shown on the button.
311See the <a href="qbutton.html#pixmap-prop">"pixmap"</a> property for details.
312<h3 class=fn>void <a name="setPopup"></a>QPushButton::setPopup ( <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;popup )
313</h3>
314Associates the popup menu <em>popup</em> with this push button. This
315turns the button into a menu button.
316<p> Ownership of the popup menu is <em>not</em> transferred to the push
317button.
318<p> <p>See also <a href="#popup">popup</a>().
319
320<p>Examples: <a href="buttongroups-example.html#x557">buttongroups/buttongroups.cpp</a> and <a href="qdir-example.html#x1836">qdir/qdir.cpp</a>.
321<h3 class=fn>void <a name="setText"></a>QButton::setText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
322</h3><p>Sets the text shown on the button.
323See the <a href="qbutton.html#text-prop">"text"</a> property for details.
324<h3 class=fn>void <a name="setToggleButton"></a>QPushButton::setToggleButton ( bool )
325</h3><p>Sets whether the button is a toggle button.
326See the <a href="qpushbutton.html#toggleButton-prop">"toggleButton"</a> property for details.
327<h3 class=fn><a href="qbutton.html#ToggleState-enum">ToggleState</a> <a name="state"></a>QButton::state () const
328</h3><p>Returns the state of the toggle button.
329See the <a href="qbutton.html#toggleState-prop">"toggleState"</a> property for details.
330<h3 class=fn>void <a name="stateChanged"></a>QButton::stateChanged ( int&nbsp;state )<tt> [signal]</tt>
331</h3>
332
333<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
334<a href="qcheckbox.html#setTristate">"no change" state</a> or <a href="qbutton.html#ToggleState-enum">Off</a>
335if the button is off.
336<p> This may be the result of a user action, <a href="qbutton.html#toggle">toggle</a>() slot activation,
337<a href="qbutton.html#setState">setState</a>(), or because <a href="#setOn">setOn</a>() was called.
338<p> <p>See also <a href="qbutton.html#clicked">clicked</a>() and <a href="qbutton.html#ToggleState-enum">QButton::ToggleState</a>.
339
340<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QButton::text () const
341</h3><p>Returns the text shown on the button.
342See the <a href="qbutton.html#text-prop">"text"</a> property for details.
343<h3 class=fn>void <a name="toggle"></a>QButton::toggle ()<tt> [slot]</tt>
344</h3>
345Toggles the state of a toggle button.
346<p> <p>See also <a href="#on-prop">on</a>, <a href="#on-prop">on</a>, <a href="qbutton.html#toggled">toggled</a>(), and <a href="#toggleButton-prop">toggleButton</a>.
347
348<h3 class=fn>void <a name="toggled"></a>QButton::toggled ( bool&nbsp;on )<tt> [signal]</tt>
349</h3>
350
351<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.
352<p> This may be the result of a user action, <a href="qbutton.html#toggle">toggle</a>() slot activation,
353or because <a href="#setOn">setOn</a>() was called.
354<p> <p>See also <a href="qbutton.html#clicked">clicked</a>().
355
356<p>Example: <a href="listbox-example.html#x1427">listbox/listbox.cpp</a>.
357<hr><h2>Property Documentation</h2>
358<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel-prop"></a>accel</h3>
359<p>This property holds the accelerator associated with the button.
360<p>This property is 0 if there is no accelerator set. If you set this
361property to 0 then any current accelerator is removed.
362
363<p>Set this property's value with <a href="#setAccel">setAccel</a>() and get this property's value with <a href="#accel">accel</a>().
364<h3 class=fn>bool <a name="autoDefault-prop"></a>autoDefault</h3>
365<p>This property holds whether the push button is the auto default button.
366<p>If this property is set to TRUE then the push button is the auto
367default button in a dialog.
368<p> In some GUI styles a default button is drawn with an extra frame
369around it, up to 3 pixels or more. Qt automatically keeps this
370space free around auto-default buttons, i.e. auto-default buttons
371may have a slightly larger size hint.
372<p> This property's default is TRUE for buttons that have a <a href="qdialog.html">QDialog</a>
373parent; otherwise it defaults to FALSE.
374<p> See the <a href="#default-prop">default</a> property for details of how <a href="#default-prop">default</a> and
375auto-default interact.
376
377<p>Set this property's value with <a href="#setAutoDefault">setAutoDefault</a>() and get this property's value with <a href="#autoDefault">autoDefault</a>().
378<h3 class=fn>bool <a name="autoMask-prop"></a>autoMask</h3>
379<p>This property holds whether the button is automatically masked.
380<p><p><p>See also <a href="qwidget.html#autoMask-prop">QWidget::autoMask</a>.
381
382<h3 class=fn>bool <a name="autoRepeat-prop"></a>autoRepeat</h3>
383<p>This property holds whether autoRepeat is enabled.
384<p>If autoRepeat is enabled then the <a href="qbutton.html#clicked">clicked</a>() signal is emitted at
385regular intervals if the button is down. This property has no
386effect on toggle buttons. autoRepeat is off by default.
387
388<p>Set this property's value with <a href="#setAutoRepeat">setAutoRepeat</a>() and get this property's value with <a href="#autoRepeat">autoRepeat</a>().
389<h3 class=fn>bool <a name="default-prop"></a>default</h3>
390<p>This property holds whether the push button is the default button.
391<p>If this property is set to TRUE then the push button will be
392pressed if the user presses the Enter (or Return) key in a dialog.
393<p> Regardless of focus, if the user presses Enter: If there is a
394default button the default button is pressed; otherwise, if
395there are one or more <a href="#autoDefault-prop">autoDefault</a> buttons the first <a href="#autoDefault-prop">autoDefault</a>
396button that is next in the tab order is pressed. If there are no
397default or <a href="#autoDefault-prop">autoDefault</a> buttons only pressing Space on a button
398with focus, mouse clicking, or using an accelerator will press a
399button.
400<p> In a dialog, only one push button at a time can be the default
401button. This button is then displayed with an additional frame
402(depending on the GUI style).
403<p> The default button behavior is provided only in dialogs. Buttons
404can always be clicked from the keyboard by pressing Enter (or
405Return) or the Spacebar when the button has focus.
406<p> This property's default is FALSE.
407
408<p>Set this property's value with <a href="#setDefault">setDefault</a>() and get this property's value with <a href="#isDefault">isDefault</a>().
409<h3 class=fn>bool <a name="flat-prop"></a>flat</h3>
410<p>This property holds whether the border is disabled.
411<p>This property's default is FALSE.
412
413<p>Set this property's value with <a href="#setFlat">setFlat</a>() and get this property's value with <a href="#isFlat">isFlat</a>().
414<h3 class=fn><a href="qiconset.html">QIconSet</a> <a name="iconSet-prop"></a>iconSet</h3>
415<p>This property holds the icon set on the push button.
416<p>This property will return 0 if the push button has no iconset.
417
418<p>Set this property's value with <a href="#setIconSet">setIconSet</a>() and get this property's value with <a href="#iconSet">iconSet</a>().
419<h3 class=fn>bool <a name="menuButton-prop"></a>menuButton</h3> <p>This property holds whether the push button has a menu button on it.
420<p><b>This property is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
421<p> If this property is set to TRUE, then a down arrow is drawn on the push
422button to indicate that a menu will pop up if the user clicks on the
423arrow.
424
425<p>Get this property's value with <a href="#isMenuButton">isMenuButton</a>().
426<h3 class=fn>bool <a name="on-prop"></a>on</h3>
427<p>This property holds whether the push button is toggled.
428<p>This property should only be set for toggle push buttons. The
429default value is FALSE.
430<p> <p>See also <a href="#on-prop">on</a>, <a href="qbutton.html#toggle">toggle</a>(), <a href="qbutton.html#toggled">toggled</a>(), and <a href="#toggleButton-prop">toggleButton</a>.
431
432<p>Set this property's value with <a href="#setOn">setOn</a>().
433<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-prop"></a>pixmap</h3>
434<p>This property holds the pixmap shown on the button.
435<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,
436this property will set the pixmap to be its own mask. The purpose
437of this is to draw transparent bitmaps which are important for
438toggle buttons, for example.
439<p> <a href="qbutton.html#pixmap">pixmap</a>() returns 0 if no pixmap was set.
440
441<p>Set this property's value with <a href="#setPixmap">setPixmap</a>() and get this property's value with <a href="#pixmap">pixmap</a>().
442<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
443<p>This property holds the text shown on the button.
444<p>This property will return a <a href="qstring.html#QString-null">QString::null</a> if the button has no
445text. If the text has an ampersand (&amp;) in it, then an
446accelerator is automatically created for it using the character
447that follows the '&amp;' as the accelerator key. Any previous
448accelerator will be overwritten, or cleared if no accelerator is
449defined by the text.
450<p> There is no default text.
451
452<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
453<h3 class=fn>bool <a name="toggleButton-prop"></a>toggleButton</h3>
454<p>This property holds whether the button is a toggle button.
455<p>Toggle buttons have an on/off state similar to <a href="qcheckbox.html">check boxes.</a> A push button is initially not a toggle
456button.
457<p> <p>See also <a href="#on-prop">on</a>, <a href="qbutton.html#toggle">toggle</a>(), <a href="#toggleButton-prop">toggleButton</a>, and <a href="qbutton.html#toggled">toggled</a>().
458
459<p>Set this property's value with <a href="#setToggleButton">setToggleButton</a>().
460<!-- eof -->
461<hr><p>
462This file is part of the <a href="index.html">Qt toolkit</a>.
463Copyright &copy; 1995-2007
464<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
465<table width=100% cellspacing=0 border=0><tr>
466<td>Copyright &copy; 2007
467<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
468<td align=right><div align=right>Qt 3.3.8</div>
469</table></div></address></body>
470</html>
Note: See TracBrowser for help on using the repository browser.