[190] | 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/qbutton.cpp:126 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QButton Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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>QButton Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QButton class is the abstract base class of button
|
---|
| 35 | widgets, providing functionality common to buttons.
|
---|
| 36 | <a href="#details">More...</a>
|
---|
| 37 | <p><tt>#include <<a href="qbutton-h.html">qbutton.h</a>></tt>
|
---|
| 38 | <p>Inherits <a href="qwidget.html">QWidget</a>.
|
---|
| 39 | <p>Inherited by <a href="qcheckbox.html">QCheckBox</a>, <a href="qpushbutton.html">QPushButton</a>, <a href="qradiobutton.html">QRadioButton</a>, and <a href="qtoolbutton.html">QToolButton</a>.
|
---|
| 40 | <p><a href="qbutton-members.html">List of all member functions.</a>
|
---|
| 41 | <h2>Public Members</h2>
|
---|
| 42 | <ul>
|
---|
| 43 | <li class=fn><a href="#QButton"><b>QButton</b></a> ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )</li>
|
---|
| 44 | <li class=fn><a href="#~QButton"><b>~QButton</b></a> ()</li>
|
---|
| 45 | <li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
|
---|
| 46 | <li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString & )</li>
|
---|
| 47 | <li class=fn>const QPixmap * <a href="#pixmap"><b>pixmap</b></a> () const</li>
|
---|
| 48 | <li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const QPixmap & )</li>
|
---|
| 49 | <li class=fn>QKeySequence <a href="#accel"><b>accel</b></a> () const</li>
|
---|
| 50 | <li class=fn>virtual void <a href="#setAccel"><b>setAccel</b></a> ( const QKeySequence & )</li>
|
---|
| 51 | <li class=fn>bool <a href="#isToggleButton"><b>isToggleButton</b></a> () const</li>
|
---|
| 52 | <li class=fn>enum <a href="#ToggleType-enum"><b>ToggleType</b></a> { SingleShot, Toggle, Tristate }</li>
|
---|
| 53 | <li class=fn>ToggleType <a href="#toggleType"><b>toggleType</b></a> () const</li>
|
---|
| 54 | <li class=fn>virtual void <a href="#setDown"><b>setDown</b></a> ( bool )</li>
|
---|
| 55 | <li class=fn>bool <a href="#isDown"><b>isDown</b></a> () const</li>
|
---|
| 56 | <li class=fn>bool <a href="#isOn"><b>isOn</b></a> () const</li>
|
---|
| 57 | <li class=fn>enum <a href="#ToggleState-enum"><b>ToggleState</b></a> { Off, NoChange, On }</li>
|
---|
| 58 | <li class=fn>ToggleState <a href="#state"><b>state</b></a> () const</li>
|
---|
| 59 | <li class=fn>bool autoResize () const <em>(obsolete)</em></li>
|
---|
| 60 | <li class=fn>void setAutoResize ( bool ) <em>(obsolete)</em></li>
|
---|
| 61 | <li class=fn>bool <a href="#autoRepeat"><b>autoRepeat</b></a> () const</li>
|
---|
| 62 | <li class=fn>virtual void <a href="#setAutoRepeat"><b>setAutoRepeat</b></a> ( bool )</li>
|
---|
| 63 | <li class=fn>bool <a href="#isExclusiveToggle"><b>isExclusiveToggle</b></a> () const</li>
|
---|
| 64 | <li class=fn>QButtonGroup * <a href="#group"><b>group</b></a> () const</li>
|
---|
| 65 | </ul>
|
---|
| 66 | <h2>Public Slots</h2>
|
---|
| 67 | <ul>
|
---|
| 68 | <li class=fn>void <a href="#animateClick"><b>animateClick</b></a> ()</li>
|
---|
| 69 | <li class=fn>void <a href="#toggle"><b>toggle</b></a> ()</li>
|
---|
| 70 | </ul>
|
---|
| 71 | <h2>Signals</h2>
|
---|
| 72 | <ul>
|
---|
| 73 | <li class=fn>void <a href="#pressed"><b>pressed</b></a> ()</li>
|
---|
| 74 | <li class=fn>void <a href="#released"><b>released</b></a> ()</li>
|
---|
| 75 | <li class=fn>void <a href="#clicked"><b>clicked</b></a> ()</li>
|
---|
| 76 | <li class=fn>void <a href="#toggled"><b>toggled</b></a> ( bool on )</li>
|
---|
| 77 | <li class=fn>void <a href="#stateChanged"><b>stateChanged</b></a> ( int state )</li>
|
---|
| 78 | </ul>
|
---|
| 79 | <h2>Properties</h2>
|
---|
| 80 | <ul>
|
---|
| 81 | <li class=fn>QKeySequence <a href="#accel-prop"><b>accel</b></a> - the accelerator associated with the button</li>
|
---|
| 82 | <li class=fn>bool <a href="#autoRepeat-prop"><b>autoRepeat</b></a> - whether autoRepeat is enabled</li>
|
---|
| 83 | <li class=fn>bool autoResize - whether autoResize is enabled <em>(obsolete)</em></li>
|
---|
| 84 | <li class=fn>bool <a href="#down-prop"><b>down</b></a> - whether the button is pressed</li>
|
---|
| 85 | <li class=fn>bool <a href="#exclusiveToggle-prop"><b>exclusiveToggle</b></a> - whether the button is an exclusive toggle <em>(read only)</em></li>
|
---|
| 86 | <li class=fn>bool <a href="#on-prop"><b>on</b></a> - whether the button is toggled <em>(read only)</em></li>
|
---|
| 87 | <li class=fn>QPixmap <a href="#pixmap-prop"><b>pixmap</b></a> - the pixmap shown on the button</li>
|
---|
| 88 | <li class=fn>QString <a href="#text-prop"><b>text</b></a> - the text shown on the button</li>
|
---|
| 89 | <li class=fn>bool <a href="#toggleButton-prop"><b>toggleButton</b></a> - whether the button is a toggle button <em>(read only)</em></li>
|
---|
| 90 | <li class=fn>ToggleState <a href="#toggleState-prop"><b>toggleState</b></a> - the state of the toggle button <em>(read only)</em></li>
|
---|
| 91 | <li class=fn>ToggleType <a href="#toggleType-prop"><b>toggleType</b></a> - the type of toggle on the button <em>(read only)</em></li>
|
---|
| 92 | </ul>
|
---|
| 93 | <h2>Protected Members</h2>
|
---|
| 94 | <ul>
|
---|
| 95 | <li class=fn>void <a href="#setToggleButton"><b>setToggleButton</b></a> ( bool b )</li>
|
---|
| 96 | <li class=fn>virtual void <a href="#setToggleType"><b>setToggleType</b></a> ( ToggleType type )</li>
|
---|
| 97 | <li class=fn>void <a href="#setOn"><b>setOn</b></a> ( bool on )</li>
|
---|
| 98 | <li class=fn>virtual void <a href="#setState"><b>setState</b></a> ( ToggleState s )</li>
|
---|
| 99 | <li class=fn>virtual bool <a href="#hitButton"><b>hitButton</b></a> ( const QPoint & pos ) const</li>
|
---|
| 100 | <li class=fn>virtual void <a href="#drawButton"><b>drawButton</b></a> ( QPainter * )</li>
|
---|
| 101 | <li class=fn>virtual void <a href="#drawButtonLabel"><b>drawButtonLabel</b></a> ( QPainter * )</li>
|
---|
| 102 | <li class=fn>virtual void <a href="#paintEvent"><b>paintEvent</b></a> ( QPaintEvent * )</li>
|
---|
| 103 | </ul>
|
---|
| 104 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | The QButton class is the abstract base class of button
|
---|
| 108 | widgets, providing functionality common to buttons.
|
---|
| 109 | <p>
|
---|
| 110 | <p> <b>If you want to create a button use <a href="qpushbutton.html">QPushButton</a>.</b>
|
---|
| 111 | <p> The QButton class implements an <em>abstract</em> button, and lets
|
---|
| 112 | subclasses specify how to reply to user actions and how to draw
|
---|
| 113 | the button.
|
---|
| 114 | <p> QButton provides both push and toggle buttons. The <a href="qradiobutton.html">QRadioButton</a>
|
---|
| 115 | and <a href="qcheckbox.html">QCheckBox</a> classes provide only toggle buttons; QPushButton and
|
---|
| 116 | <a href="qtoolbutton.html">QToolButton</a> provide both toggle and push buttons.
|
---|
| 117 | <p> Any button can have either a text or pixmap label. <a href="#setText">setText</a>() sets
|
---|
| 118 | the button to be a text button and <a href="#setPixmap">setPixmap</a>() sets it to be a
|
---|
| 119 | pixmap button. The text/pixmap is manipulated as necessary to
|
---|
| 120 | create the "disabled" appearance when the button is disabled.
|
---|
| 121 | <p> QButton provides most of the states used for buttons:
|
---|
| 122 | <ul>
|
---|
| 123 | <li> <a href="#isDown">isDown</a>() indicates whether the button is <em>pressed</em> down.
|
---|
| 124 | <li> <a href="#isOn">isOn</a>() indicates whether the button is <em>on</em>.
|
---|
| 125 | Only toggle buttons can be switched on and off (see below).
|
---|
| 126 | <li> <a href="qwidget.html#isEnabled">isEnabled</a>() indicates whether the button can be pressed by the
|
---|
| 127 | user.
|
---|
| 128 | <li> <a href="#setAutoRepeat">setAutoRepeat</a>() sets whether the button will auto-repeat
|
---|
| 129 | if the user holds it down.
|
---|
| 130 | <li> <a href="#setToggleButton">setToggleButton</a>() sets whether the button is a toggle
|
---|
| 131 | button or not.
|
---|
| 132 | </ul>
|
---|
| 133 | <p> The difference between isDown() and isOn() is as follows: When the
|
---|
| 134 | user clicks a toggle button to toggle it on, the button is first
|
---|
| 135 | <em>pressed</em> and then released into the <em>on</em> state. When the user
|
---|
| 136 | clicks it again (to toggle it off), the button moves first to the
|
---|
| 137 | <em>pressed</em> state, then to the <em>off</em> state (isOn() and isDown()
|
---|
| 138 | are both FALSE).
|
---|
| 139 | <p> Default buttons (as used in many dialogs) are provided by
|
---|
| 140 | <a href="qpushbutton.html#setDefault">QPushButton::setDefault</a>() and <a href="qpushbutton.html#setAutoDefault">QPushButton::setAutoDefault</a>().
|
---|
| 141 | <p> QButton provides five signals:
|
---|
| 142 | <ol type=1>
|
---|
| 143 | <li> <a href="#pressed">pressed</a>() is emitted when the button is pressed. E.g. with the mouse
|
---|
| 144 | or when <a href="#animateClick">animateClick</a>() is called.
|
---|
| 145 | <li> <a href="#released">released</a>() is emitted when the button is released. E.g. when the mouse
|
---|
| 146 | is released or the cursor is moved outside the widget.
|
---|
| 147 | <li> <a href="#clicked">clicked</a>() is emitted when the button is first pressed and then
|
---|
| 148 | released when the accelerator key is typed, or when
|
---|
| 149 | animateClick() is called.
|
---|
| 150 | <li> <a href="#toggled">toggled</a>(bool) is emitted when the state of a toggle button changes.
|
---|
| 151 | <li> <a href="#stateChanged">stateChanged</a>(int) is emitted when the state of a tristate
|
---|
| 152 | toggle button changes.
|
---|
| 153 | </ol>
|
---|
| 154 | <p> If the button is a text button with an ampersand (&) in its text,
|
---|
| 155 | QButton creates an automatic accelerator key. This code creates a
|
---|
| 156 | push button labelled "Ro<u>c</u>k & Roll" (where the c is
|
---|
| 157 | underlined). The button gets an automatic accelerator key, Alt+C:
|
---|
| 158 | <p> <pre>
|
---|
| 159 | <a href="qpushbutton.html">QPushButton</a> *p = new <a href="qpushbutton.html">QPushButton</a>( "Ro&ck && Roll", this );
|
---|
| 160 | </pre>
|
---|
| 161 |
|
---|
| 162 | <p> In this example, when the user presses Alt+C the button will call
|
---|
| 163 | <a href="#animateClick">animateClick</a>().
|
---|
| 164 | <p> You can also set a custom accelerator using the <a href="#setAccel">setAccel</a>()
|
---|
| 165 | function. This is useful mostly for pixmap buttons because they
|
---|
| 166 | have no automatic accelerator.
|
---|
| 167 | <p> <pre>
|
---|
| 168 | p->setPixmap( QPixmap("print.png") );
|
---|
| 169 | p->setAccel( ALT+Key_F7 );
|
---|
| 170 | </pre>
|
---|
| 171 |
|
---|
| 172 | <p> All of the buttons provided by Qt (<a href="qpushbutton.html">QPushButton</a>, <a href="qtoolbutton.html">QToolButton</a>,
|
---|
| 173 | <a href="qcheckbox.html">QCheckBox</a> and <a href="qradiobutton.html">QRadioButton</a>) can display both text and
|
---|
| 174 | pixmaps.
|
---|
| 175 | <p> To subclass QButton, you must reimplement at least <a href="#drawButton">drawButton</a>()
|
---|
| 176 | (to draw the button's outline) and <a href="#drawButtonLabel">drawButtonLabel</a>() (to draw its
|
---|
| 177 | text or pixmap). It is generally advisable to reimplement
|
---|
| 178 | <a href="qwidget.html#sizeHint">sizeHint</a>() as well, and sometimes <a href="#hitButton">hitButton</a>() (to determine
|
---|
| 179 | whether a button press is within the button).
|
---|
| 180 | <p> To reduce flickering, <a href="#paintEvent">QButton::paintEvent</a>() sets up a pixmap that
|
---|
| 181 | the drawButton() function draws in. You should not reimplement
|
---|
| 182 | <a href="#paintEvent">paintEvent</a>() for a subclass of QButton unless you want to take
|
---|
| 183 | over all drawing.
|
---|
| 184 | <p> <p>See also <a href="qbuttongroup.html">QButtonGroup</a> and <a href="abstractwidgets.html">Abstract Widget Classes</a>.
|
---|
| 185 |
|
---|
| 186 | <hr><h2>Member Type Documentation</h2>
|
---|
| 187 | <h3 class=fn><a name="ToggleState-enum"></a>QButton::ToggleState</h3>
|
---|
| 188 |
|
---|
| 189 | <p> This enum defines the state of a toggle button.
|
---|
| 190 | <ul>
|
---|
| 191 | <li><tt>QButton::Off</tt> - the button is in the "off" state
|
---|
| 192 | <li><tt>QButton::NoChange</tt> - the button is in the default/unchanged state
|
---|
| 193 | <li><tt>QButton::On</tt> - the button is in the "on" state
|
---|
| 194 | </ul>
|
---|
| 195 | <h3 class=fn><a name="ToggleType-enum"></a>QButton::ToggleType</h3>
|
---|
| 196 |
|
---|
| 197 | <p> This enum type defines what a button can do in response to a
|
---|
| 198 | mouse/keyboard press:
|
---|
| 199 | <ul>
|
---|
| 200 | <li><tt>QButton::SingleShot</tt> - pressing the button causes an action, then the
|
---|
| 201 | button returns to the unpressed state.
|
---|
| 202 | <li><tt>QButton::Toggle</tt> - pressing the button toggles it between an <a href="#ToggleState-enum">On</a> and
|
---|
| 203 | an <a href="#ToggleState-enum">Off</a> state.
|
---|
| 204 | <li><tt>QButton::Tristate</tt> - pressing the button cycles between the three
|
---|
| 205 | states <a href="#ToggleState-enum">On</a>, <a href="#ToggleState-enum">Off</a> and <a href="#ToggleState-enum">NoChange</a>
|
---|
| 206 | </ul>
|
---|
| 207 | <hr><h2>Member Function Documentation</h2>
|
---|
| 208 | <h3 class=fn><a name="QButton"></a>QButton::QButton ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0, WFlags f = 0 )
|
---|
| 209 | </h3>
|
---|
| 210 | Constructs a standard button called <em>name</em> with parent <em>parent</em>,
|
---|
| 211 | using the widget flags <em>f</em>.
|
---|
| 212 | <p> If <em>parent</em> is a <a href="qbuttongroup.html">QButtonGroup</a>, this constructor calls
|
---|
| 213 | <a href="qbuttongroup.html#insert">QButtonGroup::insert</a>().
|
---|
| 214 |
|
---|
| 215 | <h3 class=fn><a name="~QButton"></a>QButton::~QButton ()
|
---|
| 216 | </h3>
|
---|
| 217 | Destroys the button.
|
---|
| 218 |
|
---|
| 219 | <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QButton::accel () const
|
---|
| 220 | </h3><p>Returns the accelerator associated with the button.
|
---|
| 221 | See the <a href="qbutton.html#accel-prop">"accel"</a> property for details.
|
---|
| 222 | <h3 class=fn>void <a name="animateClick"></a>QButton::animateClick ()<tt> [slot]</tt>
|
---|
| 223 | </h3>
|
---|
| 224 | Performs an animated click: the button is pressed and released a
|
---|
| 225 | short while later.
|
---|
| 226 | <p> The <a href="#pressed">pressed</a>(), <a href="#released">released</a>(), <a href="#clicked">clicked</a>(), <a href="#toggled">toggled</a>(), and
|
---|
| 227 | <a href="#stateChanged">stateChanged</a>() signals are emitted as appropriate.
|
---|
| 228 | <p> This function does nothing if the button is <a href="qwidget.html#setEnabled">disabled.</a>
|
---|
| 229 | <p> <p>See also <a href="#accel-prop">accel</a>.
|
---|
| 230 |
|
---|
| 231 | <h3 class=fn>bool <a name="autoRepeat"></a>QButton::autoRepeat () const
|
---|
| 232 | </h3><p>Returns TRUE if autoRepeat is enabled; otherwise returns FALSE.
|
---|
| 233 | See the <a href="qbutton.html#autoRepeat-prop">"autoRepeat"</a> property for details.
|
---|
| 234 | <h3 class=fn>bool <a name="autoResize"></a>QButton::autoResize () const
|
---|
| 235 | </h3><p>Returns TRUE if autoResize is enabled; otherwise returns FALSE.
|
---|
| 236 | See the <a href="qbutton.html#autoResize-prop">"autoResize"</a> property for details.
|
---|
| 237 | <h3 class=fn>void <a name="clicked"></a>QButton::clicked ()<tt> [signal]</tt>
|
---|
| 238 | </h3>
|
---|
| 239 |
|
---|
| 240 | <p> This signal is emitted when the button is activated (i.e. first
|
---|
| 241 | pressed down and then released when the mouse cursor is inside the
|
---|
| 242 | button), when the accelerator key is typed or when <a href="#animateClick">animateClick</a>()
|
---|
| 243 | is called. This signal is <em>not</em> emitted if you call <a href="#setDown">setDown</a>().
|
---|
| 244 | <p> The <a href="qbuttongroup.html#clicked">QButtonGroup::clicked</a>() signal does the same job, if you want
|
---|
| 245 | to connect several buttons to the same slot.
|
---|
| 246 | <p> <b>Warning:</b> Don't launch a model dialog in response to this signal
|
---|
| 247 | for a button that has <a href="#autoRepeat-prop">autoRepeat</a> turned on.
|
---|
| 248 | <p> <p>See also <a href="#pressed">pressed</a>(), <a href="#released">released</a>(), <a href="#toggled">toggled</a>(), <a href="#autoRepeat-prop">autoRepeat</a>, and <a href="#down-prop">down</a>.
|
---|
| 249 |
|
---|
| 250 | <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>.
|
---|
| 251 | <h3 class=fn>void <a name="drawButton"></a>QButton::drawButton ( <a href="qpainter.html">QPainter</a> * )<tt> [virtual protected]</tt>
|
---|
| 252 | </h3>
|
---|
| 253 | Draws the button. The default implementation does nothing.
|
---|
| 254 | <p> This virtual function is reimplemented by subclasses to draw real
|
---|
| 255 | buttons. At some point, these reimplementations should call
|
---|
| 256 | <a href="#drawButtonLabel">drawButtonLabel</a>().
|
---|
| 257 | <p> <p>See also <a href="#drawButtonLabel">drawButtonLabel</a>() and <a href="#paintEvent">paintEvent</a>().
|
---|
| 258 |
|
---|
| 259 | <h3 class=fn>void <a name="drawButtonLabel"></a>QButton::drawButtonLabel ( <a href="qpainter.html">QPainter</a> * )<tt> [virtual protected]</tt>
|
---|
| 260 | </h3>
|
---|
| 261 | Draws the button text or pixmap.
|
---|
| 262 | <p> This virtual function is reimplemented by subclasses to draw real
|
---|
| 263 | buttons. It is invoked by <a href="#drawButton">drawButton</a>().
|
---|
| 264 | <p> <p>See also <a href="#drawButton">drawButton</a>() and <a href="#paintEvent">paintEvent</a>().
|
---|
| 265 |
|
---|
| 266 | <h3 class=fn><a href="qbuttongroup.html">QButtonGroup</a> * <a name="group"></a>QButton::group () const
|
---|
| 267 | </h3>
|
---|
| 268 | Returns the group that this button belongs to.
|
---|
| 269 | <p> If the button is not a member of any <a href="qbuttongroup.html">QButtonGroup</a>, this function
|
---|
| 270 | returns 0.
|
---|
| 271 | <p> <p>See also <a href="qbuttongroup.html">QButtonGroup</a>.
|
---|
| 272 |
|
---|
| 273 | <h3 class=fn>bool <a name="hitButton"></a>QButton::hitButton ( const <a href="qpoint.html">QPoint</a> & pos ) const<tt> [virtual protected]</tt>
|
---|
| 274 | </h3>
|
---|
| 275 | Returns TRUE if <em>pos</em> is inside the clickable button rectangle;
|
---|
| 276 | otherwise returns FALSE.
|
---|
| 277 | <p> By default, the clickable area is the entire widget. Subclasses
|
---|
| 278 | may reimplement it, though.
|
---|
| 279 |
|
---|
| 280 | <h3 class=fn>bool <a name="isDown"></a>QButton::isDown () const
|
---|
| 281 | </h3><p>Returns TRUE if the button is pressed; otherwise returns FALSE.
|
---|
| 282 | See the <a href="qbutton.html#down-prop">"down"</a> property for details.
|
---|
| 283 | <h3 class=fn>bool <a name="isExclusiveToggle"></a>QButton::isExclusiveToggle () const
|
---|
| 284 | </h3><p>Returns TRUE if the button is an exclusive toggle; otherwise returns FALSE.
|
---|
| 285 | See the <a href="qbutton.html#exclusiveToggle-prop">"exclusiveToggle"</a> property for details.
|
---|
| 286 | <h3 class=fn>bool <a name="isOn"></a>QButton::isOn () const
|
---|
| 287 | </h3><p>Returns TRUE if the button is toggled; otherwise returns FALSE.
|
---|
| 288 | See the <a href="qbutton.html#on-prop">"on"</a> property for details.
|
---|
| 289 | <h3 class=fn>bool <a name="isToggleButton"></a>QButton::isToggleButton () const
|
---|
| 290 | </h3><p>Returns TRUE if the button is a toggle button; otherwise returns FALSE.
|
---|
| 291 | See the <a href="qbutton.html#toggleButton-prop">"toggleButton"</a> property for details.
|
---|
| 292 | <h3 class=fn>void <a name="paintEvent"></a>QButton::paintEvent ( <a href="qpaintevent.html">QPaintEvent</a> * )<tt> [virtual protected]</tt>
|
---|
| 293 | </h3>
|
---|
| 294 | Handles paint events for buttons. Small and typically complex
|
---|
| 295 | buttons are painted double-buffered to reduce flicker. The
|
---|
| 296 | actually drawing is done in the virtual functions <a href="#drawButton">drawButton</a>() and
|
---|
| 297 | <a href="#drawButtonLabel">drawButtonLabel</a>().
|
---|
| 298 | <p> <p>See also <a href="#drawButton">drawButton</a>() and <a href="#drawButtonLabel">drawButtonLabel</a>().
|
---|
| 299 |
|
---|
| 300 | <p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget</a>.
|
---|
| 301 | <h3 class=fn>const <a href="qpixmap.html">QPixmap</a> * <a name="pixmap"></a>QButton::pixmap () const
|
---|
| 302 | </h3><p>Returns the pixmap shown on the button.
|
---|
| 303 | See the <a href="qbutton.html#pixmap-prop">"pixmap"</a> property for details.
|
---|
| 304 | <h3 class=fn>void <a name="pressed"></a>QButton::pressed ()<tt> [signal]</tt>
|
---|
| 305 | </h3>
|
---|
| 306 |
|
---|
| 307 | <p> This signal is emitted when the button is pressed down.
|
---|
| 308 | <p> <p>See also <a href="#released">released</a>() and <a href="#clicked">clicked</a>().
|
---|
| 309 |
|
---|
| 310 | <p>Examples: <a href="httpd-example.html#x724">network/httpd/httpd.cpp</a> and <a href="popup-example.html#x1606">popup/popup.cpp</a>.
|
---|
| 311 | <h3 class=fn>void <a name="released"></a>QButton::released ()<tt> [signal]</tt>
|
---|
| 312 | </h3>
|
---|
| 313 |
|
---|
| 314 | <p> This signal is emitted when the button is released.
|
---|
| 315 | <p> <p>See also <a href="#pressed">pressed</a>(), <a href="#clicked">clicked</a>(), and <a href="#toggled">toggled</a>().
|
---|
| 316 |
|
---|
| 317 | <h3 class=fn>void <a name="setAccel"></a>QButton::setAccel ( const <a href="qkeysequence.html">QKeySequence</a> & )<tt> [virtual]</tt>
|
---|
| 318 | </h3><p>Sets the accelerator associated with the button.
|
---|
| 319 | See the <a href="qbutton.html#accel-prop">"accel"</a> property for details.
|
---|
| 320 | <h3 class=fn>void <a name="setAutoRepeat"></a>QButton::setAutoRepeat ( bool )<tt> [virtual]</tt>
|
---|
| 321 | </h3><p>Sets whether autoRepeat is enabled.
|
---|
| 322 | See the <a href="qbutton.html#autoRepeat-prop">"autoRepeat"</a> property for details.
|
---|
| 323 | <h3 class=fn>void <a name="setAutoResize"></a>QButton::setAutoResize ( bool )
|
---|
| 324 | </h3><p>Sets whether autoResize is enabled.
|
---|
| 325 | See the <a href="qbutton.html#autoResize-prop">"autoResize"</a> property for details.
|
---|
| 326 | <h3 class=fn>void <a name="setDown"></a>QButton::setDown ( bool )<tt> [virtual]</tt>
|
---|
| 327 | </h3><p>Sets whether the button is pressed.
|
---|
| 328 | See the <a href="qbutton.html#down-prop">"down"</a> property for details.
|
---|
| 329 | <h3 class=fn>void <a name="setOn"></a>QButton::setOn ( bool on )<tt> [protected]</tt>
|
---|
| 330 | </h3>
|
---|
| 331 |
|
---|
| 332 | <p> Sets the state of this button to On if <em>on</em> is TRUE; otherwise to
|
---|
| 333 | Off.
|
---|
| 334 | <p> <p>See also <a href="#toggleState-prop">toggleState</a>.
|
---|
| 335 |
|
---|
| 336 | <h3 class=fn>void <a name="setPixmap"></a>QButton::setPixmap ( const <a href="qpixmap.html">QPixmap</a> & )<tt> [virtual]</tt>
|
---|
| 337 | </h3><p>Sets the pixmap shown on the button.
|
---|
| 338 | See the <a href="qbutton.html#pixmap-prop">"pixmap"</a> property for details.
|
---|
| 339 | <h3 class=fn>void <a name="setState"></a>QButton::setState ( <a href="qbutton.html#ToggleState-enum">ToggleState</a> s )<tt> [virtual protected]</tt>
|
---|
| 340 | </h3>
|
---|
| 341 | Sets the toggle state of the button to <em>s</em>. <em>s</em> can be <a href="#ToggleState-enum">Off</a>, <a href="#ToggleState-enum">NoChange</a> or <a href="#ToggleState-enum">On</a>.
|
---|
| 342 |
|
---|
| 343 | <h3 class=fn>void <a name="setText"></a>QButton::setText ( const <a href="qstring.html">QString</a> & )<tt> [virtual]</tt>
|
---|
| 344 | </h3><p>Sets the text shown on the button.
|
---|
| 345 | See the <a href="qbutton.html#text-prop">"text"</a> property for details.
|
---|
| 346 | <h3 class=fn>void <a name="setToggleButton"></a>QButton::setToggleButton ( bool b )<tt> [protected]</tt>
|
---|
| 347 | </h3>
|
---|
| 348 |
|
---|
| 349 | <p> If <em>b</em> is TRUE, this button becomes a toggle button; if <em>b</em> is
|
---|
| 350 | FALSE, this button becomes a command button.
|
---|
| 351 | <p> <p>See also <a href="#toggleButton-prop">toggleButton</a>.
|
---|
| 352 |
|
---|
| 353 | <h3 class=fn>void <a name="setToggleType"></a>QButton::setToggleType ( <a href="qbutton.html#ToggleType-enum">ToggleType</a> type )<tt> [virtual protected]</tt>
|
---|
| 354 | </h3>
|
---|
| 355 | Sets the toggle type of the button to <em>type</em>.
|
---|
| 356 | <p> <em>type</em> can be set to <a href="#ToggleType-enum">SingleShot</a>, <a href="#ToggleType-enum">Toggle</a> and <a href="#ToggleType-enum">Tristate</a>.
|
---|
| 357 |
|
---|
| 358 | <h3 class=fn><a href="qbutton.html#ToggleState-enum">ToggleState</a> <a name="state"></a>QButton::state () const
|
---|
| 359 | </h3><p>Returns the state of the toggle button.
|
---|
| 360 | See the <a href="qbutton.html#toggleState-prop">"toggleState"</a> property for details.
|
---|
| 361 | <h3 class=fn>void <a name="stateChanged"></a>QButton::stateChanged ( int state )<tt> [signal]</tt>
|
---|
| 362 | </h3>
|
---|
| 363 |
|
---|
| 364 | <p> This signal is emitted whenever a toggle button changes state. <em>state</em> is <a href="#ToggleState-enum">On</a> if the button is on, <a href="#ToggleState-enum">NoChange</a> if it is in the
|
---|
| 365 | <a href="qcheckbox.html#setTristate">"no change" state</a> or <a href="#ToggleState-enum">Off</a>
|
---|
| 366 | if the button is off.
|
---|
| 367 | <p> This may be the result of a user action, <a href="#toggle">toggle</a>() slot activation,
|
---|
| 368 | <a href="#setState">setState</a>(), or because <a href="#setOn">setOn</a>() was called.
|
---|
| 369 | <p> <p>See also <a href="#clicked">clicked</a>() and <a href="#ToggleState-enum">QButton::ToggleState</a>.
|
---|
| 370 |
|
---|
| 371 | <h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QButton::text () const
|
---|
| 372 | </h3><p>Returns the text shown on the button.
|
---|
| 373 | See the <a href="qbutton.html#text-prop">"text"</a> property for details.
|
---|
| 374 | <h3 class=fn>void <a name="toggle"></a>QButton::toggle ()<tt> [slot]</tt>
|
---|
| 375 | </h3>
|
---|
| 376 | Toggles the state of a toggle button.
|
---|
| 377 | <p> <p>See also <a href="#on-prop">on</a>, <a href="#setOn">setOn</a>(), <a href="#toggled">toggled</a>(), and <a href="#toggleButton-prop">toggleButton</a>.
|
---|
| 378 |
|
---|
| 379 | <h3 class=fn><a href="qbutton.html#ToggleType-enum">ToggleType</a> <a name="toggleType"></a>QButton::toggleType () const
|
---|
| 380 | </h3><p>Returns the type of toggle on the button.
|
---|
| 381 | See the <a href="qbutton.html#toggleType-prop">"toggleType"</a> property for details.
|
---|
| 382 | <h3 class=fn>void <a name="toggled"></a>QButton::toggled ( bool on )<tt> [signal]</tt>
|
---|
| 383 | </h3>
|
---|
| 384 |
|
---|
| 385 | <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.
|
---|
| 386 | <p> This may be the result of a user action, <a href="#toggle">toggle</a>() slot activation,
|
---|
| 387 | or because <a href="#setOn">setOn</a>() was called.
|
---|
| 388 | <p> <p>See also <a href="#clicked">clicked</a>().
|
---|
| 389 |
|
---|
| 390 | <p>Example: <a href="listbox-example.html#x1427">listbox/listbox.cpp</a>.
|
---|
| 391 | <hr><h2>Property Documentation</h2>
|
---|
| 392 | <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel-prop"></a>accel</h3>
|
---|
| 393 | <p>This property holds the accelerator associated with the button.
|
---|
| 394 | <p>This property is 0 if there is no accelerator set. If you set this
|
---|
| 395 | property to 0 then any current accelerator is removed.
|
---|
| 396 |
|
---|
| 397 | <p>Set this property's value with <a href="#setAccel">setAccel</a>() and get this property's value with <a href="#accel">accel</a>().
|
---|
| 398 | <h3 class=fn>bool <a name="autoRepeat-prop"></a>autoRepeat</h3>
|
---|
| 399 | <p>This property holds whether autoRepeat is enabled.
|
---|
| 400 | <p>If autoRepeat is enabled then the <a href="#clicked">clicked</a>() signal is emitted at
|
---|
| 401 | regular intervals if the button is down. This property has no
|
---|
| 402 | effect on toggle buttons. autoRepeat is off by default.
|
---|
| 403 |
|
---|
| 404 | <p>Set this property's value with <a href="#setAutoRepeat">setAutoRepeat</a>() and get this property's value with <a href="#autoRepeat">autoRepeat</a>().
|
---|
| 405 | <h3 class=fn>bool <a name="autoResize-prop"></a>autoResize</h3> <p>This property holds whether autoResize is enabled.
|
---|
| 406 | <p><b>This property is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 407 | <p> If autoResize is enabled then the button will resize itself
|
---|
| 408 | whenever the contents are changed.
|
---|
| 409 |
|
---|
| 410 | <p>Set this property's value with <a href="#setAutoResize">setAutoResize</a>() and get this property's value with <a href="#autoResize">autoResize</a>().
|
---|
| 411 | <h3 class=fn>bool <a name="down-prop"></a>down</h3>
|
---|
| 412 | <p>This property holds whether the button is pressed.
|
---|
| 413 | <p>If this property is TRUE, the button is pressed down. The signals
|
---|
| 414 | <a href="#pressed">pressed</a>() and <a href="#clicked">clicked</a>() are not emitted if you set this property
|
---|
| 415 | to TRUE. The default is FALSE.
|
---|
| 416 |
|
---|
| 417 | <p>Set this property's value with <a href="#setDown">setDown</a>() and get this property's value with <a href="#isDown">isDown</a>().
|
---|
| 418 | <h3 class=fn>bool <a name="exclusiveToggle-prop"></a>exclusiveToggle</h3>
|
---|
| 419 | <p>This property holds whether the button is an exclusive toggle.
|
---|
| 420 | <p>If this property is TRUE and the button is in a <a href="qbuttongroup.html">QButtonGroup</a>, the
|
---|
| 421 | button can only be toggled off by another one being toggled on.
|
---|
| 422 | The default is FALSE.
|
---|
| 423 |
|
---|
| 424 | <p>Get this property's value with <a href="#isExclusiveToggle">isExclusiveToggle</a>().
|
---|
| 425 | <h3 class=fn>bool <a name="on-prop"></a>on</h3>
|
---|
| 426 | <p>This property holds whether the button is toggled.
|
---|
| 427 | <p>This property should only be set for toggle buttons.
|
---|
| 428 |
|
---|
| 429 | <p>Get this property's value with <a href="#isOn">isOn</a>().
|
---|
| 430 | <h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-prop"></a>pixmap</h3>
|
---|
| 431 | <p>This property holds the pixmap shown on the button.
|
---|
| 432 | <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,
|
---|
| 433 | this property will set the pixmap to be its own mask. The purpose
|
---|
| 434 | of this is to draw transparent bitmaps which are important for
|
---|
| 435 | toggle buttons, for example.
|
---|
| 436 | <p> <a href="#pixmap">pixmap</a>() returns 0 if no pixmap was set.
|
---|
| 437 |
|
---|
| 438 | <p>Set this property's value with <a href="#setPixmap">setPixmap</a>() and get this property's value with <a href="#pixmap">pixmap</a>().
|
---|
| 439 | <h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
|
---|
| 440 | <p>This property holds the text shown on the button.
|
---|
| 441 | <p>This property will return a <a href="qstring.html#QString-null">QString::null</a> if the button has no
|
---|
| 442 | text. If the text has an ampersand (&) in it, then an
|
---|
| 443 | accelerator is automatically created for it using the character
|
---|
| 444 | that follows the '&' as the accelerator key. Any previous
|
---|
| 445 | accelerator will be overwritten, or cleared if no accelerator is
|
---|
| 446 | defined by the text.
|
---|
| 447 | <p> There is no default text.
|
---|
| 448 |
|
---|
| 449 | <p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
|
---|
| 450 | <h3 class=fn>bool <a name="toggleButton-prop"></a>toggleButton</h3>
|
---|
| 451 | <p>This property holds whether the button is a toggle button.
|
---|
| 452 | <p>The default value is FALSE.
|
---|
| 453 |
|
---|
| 454 | <p>Get this property's value with <a href="#isToggleButton">isToggleButton</a>().
|
---|
| 455 | <h3 class=fn><a href="qbutton.html#ToggleState-enum">ToggleState</a> <a name="toggleState-prop"></a>toggleState</h3>
|
---|
| 456 | <p>This property holds the state of the toggle button.
|
---|
| 457 | <p>If this property is changed then it does not cause the button
|
---|
| 458 | to be repainted.
|
---|
| 459 |
|
---|
| 460 | <p>Get this property's value with <a href="#state">state</a>().
|
---|
| 461 | <h3 class=fn><a href="qbutton.html#ToggleType-enum">ToggleType</a> <a name="toggleType-prop"></a>toggleType</h3>
|
---|
| 462 | <p>This property holds the type of toggle on the button.
|
---|
| 463 | <p>The default toggle type is <a href="#ToggleType-enum">SingleShot</a>.
|
---|
| 464 | <p> <p>See also <a href="#ToggleType-enum">QButton::ToggleType</a>.
|
---|
| 465 |
|
---|
| 466 | <p>Get this property's value with <a href="#toggleType">toggleType</a>().
|
---|
| 467 | <!-- eof -->
|
---|
| 468 | <hr><p>
|
---|
| 469 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 470 | Copyright © 1995-2007
|
---|
| 471 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 472 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 473 | <td>Copyright © 2007
|
---|
| 474 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 475 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 476 | </table></div></address></body>
|
---|
| 477 | </html>
|
---|