Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > ac91357d6caede925de099a02fced14e > files > 4517

qt4-doc-4.2.1-1.el5_7.1.x86_64.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/gui/widgets/qpushbutton.cpp -->
<head>
  <title>Qt 4.2: QPushButton Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QPushButton Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QPushButton widget provides a command button. <a href="#details">More...</a></p>
<pre> #include &lt;QPushButton&gt;</pre><p>Inherits <a href="qabstractbutton.html">QAbstractButton</a>.</p>
<ul>
<li><a href="qpushbutton-members.html">List of all members, including inherited members</a></li>
<li><a href="qpushbutton-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<ul>
<li><div class="fn"/><b><a href="qpushbutton.html#autoDefault-prop">autoDefault</a></b> : bool</li>
<li><div class="fn"/><b><a href="qpushbutton.html#default-prop">default</a></b> : bool</li>
<li><div class="fn"/><b><a href="qpushbutton.html#flat-prop">flat</a></b> : bool</li>
</ul>
<ul>
<li><div class="fn"/>11 properties inherited from <a href="qabstractbutton.html#properties">QAbstractButton</a></li>
<li><div class="fn"/>55 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qpushbutton.html#QPushButton">QPushButton</a></b> ( QWidget * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qpushbutton.html#QPushButton-2">QPushButton</a></b> ( const QString &amp; <i>text</i>, QWidget * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qpushbutton.html#QPushButton-3">QPushButton</a></b> ( const QIcon &amp; <i>icon</i>, const QString &amp; <i>text</i>, QWidget * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qpushbutton.html#dtor.QPushButton">~QPushButton</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qpushbutton.html#autoDefault-prop">autoDefault</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qpushbutton.html#default-prop">isDefault</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qpushbutton.html#flat-prop">isFlat</a></b> () const</li>
<li><div class="fn"/>QMenu * <b><a href="qpushbutton.html#menu">menu</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qpushbutton.html#autoDefault-prop">setAutoDefault</a></b> ( bool )</li>
<li><div class="fn"/>void <b><a href="qpushbutton.html#default-prop">setDefault</a></b> ( bool )</li>
<li><div class="fn"/>void <b><a href="qpushbutton.html#flat-prop">setFlat</a></b> ( bool )</li>
<li><div class="fn"/>void <b><a href="qpushbutton.html#setMenu">setMenu</a></b> ( QMenu * <i>menu</i> )</li>
</ul>
<ul>
<li><div class="fn"/>21 public functions inherited from <a href="qabstractbutton.html#public-functions">QAbstractButton</a></li>
<li><div class="fn"/>195 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div class="fn"/>12 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>void <b><a href="qpushbutton.html#showMenu">showMenu</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>5 public slots inherited from <a href="qabstractbutton.html#public-slots">QAbstractButton</a></li>
<li><div class="fn"/>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>4 signals inherited from <a href="qabstractbutton.html#signals">QAbstractButton</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>3 protected functions inherited from <a href="qabstractbutton.html#protected-functions">QAbstractButton</a></li>
<li><div class="fn"/>38 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"/>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li><div class="fn"/>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QPushButton widget provides a command button.</p>
<p>The push button, or command button, is perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.</p>
<p>A command button is rectangular and typically displays a text label describing its action. An underlined character in the label (signified by preceding it with an ampersand in the text) indicates a shortcut key, e.g.</p>
<pre> QPushButton *pb = new QPushButton(&quot;&amp;Download&quot;, this);</pre>
<p>In this example the shortcut is <i>Alt+D</i>, and the label text will be displayed as <b><u>D</u>ownload</b>.</p>
<p>Push buttons display a textual label, and optionally a small icon. These can be set using the constructors and changed later using <a href="qabstractbutton.html#text-prop">setText</a>() and <a href="qabstractbutton.html#icon-prop">setIcon</a>(). If the button is disabled the appearance of the text and icon will be manipulated with respect to the GUI style to make the button look &quot;disabled&quot;.</p>
<p>A push button emits the signal <a href="qabstractbutton.html#clicked">clicked</a>() when it is activated by the mouse, the Spacebar or by a keyboard shortcut. Connect to this signal to perform the button's action. Push buttons also provide less commonly used signals, for example, <a href="qabstractbutton.html#pressed">pressed</a>() and <a href="qabstractbutton.html#released">released</a>().</p>
<p>Command buttons in dialogs are by default auto-default buttons, i.e. they become the default push button automatically when they receive the keyboard input focus. A default button is a push button that is activated when the user presses the Enter or Return key in a dialog. You can change this with <a href="qpushbutton.html#autoDefault-prop">setAutoDefault</a>(). Note that auto-default buttons reserve a little extra space which is necessary to draw a default-button indicator. If you do not want this space around your buttons, call setAutoDefault(false).</p>
<p>Being so central, the button widget has grown to accommodate a great many variations in the past decade. The Microsoft style guide now shows about ten different states of Windows push buttons and the text implies that there are dozens more when all the combinations of features are taken into consideration.</p>
<p>The most important modes or states are:</p>
<ul>
<li>Available or not (grayed out, disabled).</li>
<li>Standard push button, toggling push button or menu button.</li>
<li>On or off (only for toggling push buttons).</li>
<li>Default or normal. The default button in a dialog can generally be &quot;clicked&quot; using the Enter or Return key.</li>
<li>Auto-repeat or not.</li>
<li>Pressed down or not.</li>
</ul>
<p>As a general rule, use a push button when the application or dialog window performs an action when the user clicks on it (such as Apply, Cancel, Close and Help) <i>and</i> when the widget is supposed to have a wide, rectangular shape with a text label. Small, typically square buttons that change the state of the window rather than performing an action (such as the buttons in the top-right corner of the <a href="qfiledialog.html">QFileDialog</a>) are not command buttons, but tool buttons. Qt provides a special class (<a href="qtoolbutton.html">QToolButton</a>) for these buttons.</p>
<p>If you need toggle behavior (see <a href="qabstractbutton.html#checkable-prop">setCheckable</a>()) or a button that auto-repeats the activation signal when being pushed down like the arrows in a scroll bar (see <a href="qabstractbutton.html#autoRepeat-prop">setAutoRepeat</a>()), a command button is probably not what you want. When in doubt, use a tool button.</p>
<p>A variation of a command button is a menu button. These provide not just one command, but several, since when they are clicked they pop up a menu of options. Use the method <a href="qpushbutton.html#setMenu">setMenu</a>() to associate a popup menu with a push button.</p>
<p>Other classes of buttons are option buttons (see <a href="qradiobutton.html">QRadioButton</a>) and check boxes (see <a href="qcheckbox.html">QCheckBox</a>).</p>
<p><table width="100%" align="center" cellpadding="2" cellspacing="1" border="0">
<tr valign="top" class="odd"><td><img src="images/macintosh-pushbutton.png" alt="Screenshot of a Macintosh style push button" /></td><td>A push button shown in the <a href="gallery-macintosh.html">Macintosh widget style</a>.</td></tr>
<tr valign="top" class="even"><td><img src="images/windowsxp-pushbutton.png" alt="Screenshot of a Windows XP style push button" /></td><td>A push button shown in the <a href="gallery-windowsxp.html">Windows XP widget style</a>.</td></tr>
<tr valign="top" class="odd"><td><img src="images/plastique-pushbutton.png" alt="Screenshot of a Plastique style push button" /></td><td>A push button shown in the <a href="gallery-plastique.html">Plastique widget style</a>.</td></tr>
</table></p>
<p>In Qt, the <a href="qabstractbutton.html">QAbstractButton</a> base class provides most of the modes and other API, and QPushButton provides GUI logic. See <a href="qabstractbutton.html">QAbstractButton</a> for more information about the API.</p>
<p>See also <a href="qtoolbutton.html">QToolButton</a>, <a href="qradiobutton.html">QRadioButton</a>, <a href="qcheckbox.html">QCheckBox</a>, and <a href="guibooks.html#fowler">GUI Design Handbook: Push Button</a>.</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="autoDefault-prop"></a>autoDefault : bool</h3>
<p>This property holds whether the push button is the auto default button.</p>
<p>If this property is set to true then the push button is the auto default button in a dialog.</p>
<p>In some GUI styles a default button is drawn with an extra frame around it, up to 3 pixels or more. Qt automatically keeps this space free around auto-default buttons, i.e. auto-default buttons may have a slightly larger size hint.</p>
<p>This property's default is true for buttons that have a <a href="qdialog.html">QDialog</a> parent; otherwise it defaults to false.</p>
<p>See the <a href="qpushbutton.html#default-prop">default</a> property for details of how <a href="qpushbutton.html#default-prop">default</a> and auto-default interact.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool autoDefault () const</b></li>
<li><div class="fn"/><b>void setAutoDefault ( bool )</b></li>
</ul>
<h3 class="fn"><a name="default-prop"></a>default : bool</h3>
<p>This property holds whether the push button is the default button.</p>
<p>If this property is set to true then the push button will be pressed if the user presses the Enter (or Return) key in a dialog.</p>
<p>Regardless of focus, if the user presses Enter: If there is a default button the default button is pressed; otherwise, if there are one or more <a href="qpushbutton.html#autoDefault-prop">autoDefault</a> buttons the first <a href="qpushbutton.html#autoDefault-prop">autoDefault</a> button that is next in the tab order is pressed. If there are no default or <a href="qpushbutton.html#autoDefault-prop">autoDefault</a> buttons only pressing Space on a button with focus, mouse clicking, or using a shortcut will press a button.</p>
<p>In a dialog, only one push button at a time can be the default button. This button is then displayed with an additional frame (depending on the GUI style).</p>
<p>The default button behavior is provided only in dialogs. Buttons can always be clicked from the keyboard by pressing Spacebar when the button has focus.</p>
<p>This property's default is false.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isDefault () const</b></li>
<li><div class="fn"/><b>void setDefault ( bool )</b></li>
</ul>
<h3 class="fn"><a name="flat-prop"></a>flat : bool</h3>
<p>This property holds whether the border is disabled.</p>
<p>This property's default is false.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>bool isFlat () const</b></li>
<li><div class="fn"/><b>void setFlat ( bool )</b></li>
</ul>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QPushButton"></a>QPushButton::QPushButton ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a push button with no text and a <i>parent</i>.</p>
<h3 class="fn"><a name="QPushButton-2"></a>QPushButton::QPushButton ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a push button with the parent <i>parent</i> and the text <i>text</i>.</p>
<h3 class="fn"><a name="QPushButton-3"></a>QPushButton::QPushButton ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a push button with an <i>icon</i> and a <i>text</i>, and a <i>parent</i>.</p>
<p>Note that you can also pass a <a href="qpixmap.html">QPixmap</a> object as an icon (thanks to the implicit type conversion provided by C++).</p>
<h3 class="fn"><a name="dtor.QPushButton"></a>QPushButton::~QPushButton ()</h3>
<p>Destroys the push button.</p>
<h3 class="fn"><a name="menu"></a><a href="qmenu.html">QMenu</a> * QPushButton::menu () const</h3>
<p>Returns the button's associated popup menu or 0 if no popup menu has been set.</p>
<p>See also <a href="qpushbutton.html#setMenu">setMenu</a>().</p>
<h3 class="fn"><a name="setMenu"></a>void QPushButton::setMenu ( <a href="qmenu.html">QMenu</a> * <i>menu</i> )</h3>
<p>Associates the popup menu <i>menu</i> with this push button. This turns the button into a menu button, which in some styles will produce a small triangle to the right of the button's text.</p>
<p>Ownership of the menu is <i>not</i> transferred to the push button.</p>
<p>See also <a href="qpushbutton.html#menu">menu</a>().</p>
<h3 class="fn"><a name="showMenu"></a>void QPushButton::showMenu ()&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>Shows (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QPushButton-4"></a>QPushButton::QPushButton ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const char * <i>name</i> )</h3>
<p>Use one of the constructors that doesn't take the <i>name</i> argument and then use <a href="qobject.html#objectName-prop">setObjectName</a>() instead.</p>
<h3 class="fn"><a name="QPushButton-5"></a>QPushButton::QPushButton ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i>, const char * <i>name</i> )</h3>
<p>Use one of the constructors that doesn't take the <i>name</i> argument and then use <a href="qobject.html#objectName-prop">setObjectName</a>() instead.</p>
<h3 class="fn"><a name="QPushButton-6"></a>QPushButton::QPushButton ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i>, const char * <i>name</i> )</h3>
<p>Use one of the constructors that doesn't take the <i>name</i> argument and then use <a href="qobject.html#objectName-prop">setObjectName</a>() instead.</p>
<h3 class="fn"><a name="isMenuButton"></a>bool QPushButton::isMenuButton () const</h3>
<p>Use <a href="qpushbutton.html#menu">menu</a>() != 0 instead.</p>
<h3 class="fn"><a name="openPopup"></a>void QPushButton::openPopup ()</h3>
<p>Use <a href="qpushbutton.html#showMenu">showMenu</a>() instead.</p>
<h3 class="fn"><a name="popup"></a><a href="qmenu.html">QMenu</a> * QPushButton::popup () const</h3>
<p>Use <a href="qpushbutton.html#menu">menu</a>() instead.</p>
<p>See also <a href="qpushbutton-qt3.html#setPopup">setPopup</a>().</p>
<h3 class="fn"><a name="setPopup"></a>void QPushButton::setPopup ( <a href="qmenu.html">QMenu</a> * <i>popup</i> )</h3>
<p>Use <a href="qpushbutton.html#setMenu">setMenu</a>() instead.</p>
<p>See also <a href="qpushbutton-qt3.html#popup">popup</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>