<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/widgets/qbuttongroup.cpp:46 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QButtonGroup Class</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QButtonGroup Class Reference</h1> <p>The QButtonGroup widget organizes QButton widgets in a group. <a href="#details">More...</a> <p><tt>#include <<a href="qbuttongroup-h.html">qbuttongroup.h</a>></tt> <p>Inherits <a href="qgroupbox.html">QGroupBox</a>. <p>Inherited by <a href="qhbuttongroup.html">QHButtonGroup</a> and <a href="qvbuttongroup.html">QVButtonGroup</a>. <p><a href="qbuttongroup-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li><div class=fn><a href="#QButtonGroup"><b>QButtonGroup</b></a> ( QWidget * parent = 0, const char * name = 0 )</div></li> <li><div class=fn><a href="#QButtonGroup-2"><b>QButtonGroup</b></a> ( const QString & title, QWidget * parent = 0, const char * name = 0 )</div></li> <li><div class=fn><a href="#QButtonGroup-3"><b>QButtonGroup</b></a> ( int strips, Orientation orientation, QWidget * parent = 0, const char * name = 0 )</div></li> <li><div class=fn><a href="#QButtonGroup-4"><b>QButtonGroup</b></a> ( int strips, Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0 )</div></li> <li><div class=fn>bool <a href="#isExclusive"><b>isExclusive</b></a> () const</div></li> <li><div class=fn>bool <a href="#isRadioButtonExclusive"><b>isRadioButtonExclusive</b></a> () const</div></li> <li><div class=fn>virtual void <a href="#setExclusive"><b>setExclusive</b></a> ( bool )</div></li> <li><div class=fn>virtual void <a href="#setRadioButtonExclusive"><b>setRadioButtonExclusive</b></a> ( bool )</div></li> <li><div class=fn>int <a href="#insert"><b>insert</b></a> ( QButton * button, int id = -1 )</div></li> <li><div class=fn>void <a href="#remove"><b>remove</b></a> ( QButton * button )</div></li> <li><div class=fn>QButton * <a href="#find"><b>find</b></a> ( int id ) const</div></li> <li><div class=fn>int <a href="#id"><b>id</b></a> ( QButton * button ) const</div></li> <li><div class=fn>int <a href="#count"><b>count</b></a> () const</div></li> <li><div class=fn>virtual void <a href="#setButton"><b>setButton</b></a> ( int id )</div></li> <li><div class=fn>virtual void <a href="#moveFocus"><b>moveFocus</b></a> ( int key )</div></li> <li><div class=fn>QButton * <a href="#selected"><b>selected</b></a> () const</div></li> </ul> <h2>Signals</h2> <ul> <li><div class=fn>void <a href="#pressed"><b>pressed</b></a> ( int id )</div></li> <li><div class=fn>void <a href="#released"><b>released</b></a> ( int id )</div></li> <li><div class=fn>void <a href="#clicked"><b>clicked</b></a> ( int id )</div></li> </ul> <h2>Properties</h2> <ul> <li><div class=fn>bool <a href="#exclusive-prop"><b>exclusive</b></a> - whether the button group is exclusive</div></li> <li><div class=fn>bool <a href="#radioButtonExclusive-prop"><b>radioButtonExclusive</b></a> - whether the radiobuttons in the group are exclusive</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QButtonGroup widget organizes <a href="qbutton.html">QButton</a> widgets in a group. <p> <p> A button group widget makes it easier to deal with groups of buttons. Each button in a button group has a unique identifier. The button group emits a <a href="#clicked">clicked</a>() signal with this identifier when the button is clicked. This makes a button group particularly useful when you have several similar buttons and want to connect all their clicked() signals to one slot. <p> An <a href="#setExclusive">exclusive</a> button group switches off all toggle buttons except the one that was clicked. A button group is by default non-exclusive. By default, all radio buttons that are inserted will be mutually exclusive even if the button group is non-exclusive. (See <a href="#setRadioButtonExclusive">setRadioButtonExclusive</a>().) <p> There are two ways of using a button group: <ul> <li> The button group is a parent widget of a number of buttons, i.e., the button group is the parent argument in the button constructor. The buttons are assigned identifiers 0, 1, 2, etc. in the order they are created. A QButtonGroup can display a frame and a title because it inherits <a href="qgroupbox.html">QGroupBox</a>. <li> The button group is an invisible widget and the contained buttons have some other parent widget. A button must then be manually inserted using the <a href="#insert">insert</a>() function with an identifier. </ul> <p> A button can be removed from the group with <a href="#remove">remove</a>(). A pointer to a button with a given id can be obtained using <a href="#find">find</a>(). The id of a button is available using <a href="#id">id</a>(). A button can be set on with <a href="#setButton">setButton</a>(). The number of buttons in the group is returned by <a href="#count">count</a>(). <p> <img src=qbttngrp-m.png> <img src=qbttngrp-w.png> <p> <p>See also <a href="qbutton.html">QButton</a>, <a href="qpushbutton.html">QPushButton</a>, <a href="qcheckbox.html">QCheckBox</a>, <a href="qradiobutton.html">QRadioButton</a>, <a href="appearance.html">Widget Appearance and Style</a>, <a href="geomanagement.html">Layout Management</a> and <a href="organizers.html">Organizers</a>. <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QButtonGroup"></a>QButtonGroup::QButtonGroup ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 ) </h3> Constructs a button group with no title. <p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qwidget.html">QWidget</a> constructor. <h3 class=fn><a name="QButtonGroup-2"></a>QButtonGroup::QButtonGroup ( const <a href="qstring.html">QString</a> & title, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 ) </h3> Constructs a button group with the title <em>title</em>. <p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qwidget.html">QWidget</a> constructor. <h3 class=fn><a name="QButtonGroup-3"></a>QButtonGroup::QButtonGroup ( int strips, <a href="qt.html#Orientation-enum">Orientation</a> orientation, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 ) </h3> Constructs a button group with no title. Child widgets will be arranged in <em>strips</em> rows or columns (depending on <em>orientation</em>). <p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qwidget.html">QWidget</a> constructor. <h3 class=fn><a name="QButtonGroup-4"></a>QButtonGroup::QButtonGroup ( int strips, <a href="qt.html#Orientation-enum">Orientation</a> orientation, const <a href="qstring.html">QString</a> & title, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 ) </h3> Constructs a button group with title <em>title</em>. Child widgets will be arranged in <em>strips</em> rows or columns (depending on <em>orientation</em>). <p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qwidget.html">QWidget</a> constructor. <h3 class=fn>void <a name="clicked"></a>QButtonGroup::clicked ( int id )<tt> [signal]</tt> </h3> <p> This signal is emitted when a button in the group is clicked. The <em>id</em> argument is the button's identifier. <p> <p>See also <a href="qbutton.html#clicked">QButton::clicked</a>() and <a href="#insert">insert</a>(). <p>Examples: <a href="drawdemo-example.html#x1630">drawdemo/drawdemo.cpp</a> and <a href="xform-example.html#x75">xform/xform.cpp</a>. <h3 class=fn>int <a name="count"></a>QButtonGroup::count () const </h3> Returns the number of buttons in the group. <h3 class=fn><a href="qbutton.html">QButton</a> * <a name="find"></a>QButtonGroup::find ( int id ) const </h3> Finds and returns a pointer to the button with the specified identifier <em>id</em>. <p> Returns null if the button was not found. <h3 class=fn>int <a name="id"></a>QButtonGroup::id ( <a href="qbutton.html">QButton</a> * button ) const </h3> Returns the id of <em>button</em>, or -1 if <em>button</em> is not a member of this group. <h3 class=fn>int <a name="insert"></a>QButtonGroup::insert ( <a href="qbutton.html">QButton</a> * button, int id = -1 ) </h3> Inserts the <em>button</em> with the identifier <em>id</em> into the button group. Returns the button identifier. <p> Buttons are normally inserted into a button group automatically by giving the button group as the parent when the button is constructed. So it is not necessary to manually insert buttons that have this button group as their parent widget. An exception is when you want custom identifiers instead of the default 0, 1, 2, etc. <p> The button is assigned the identifier <em>id</em> or an automatically generated identifier. It works as follows: If <em>id</em> >= 0, this identifier is assigned. If <em>id</em> == -1 (default), the identifier is equal to the number of buttons in the group. If <em>id</em> is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated. No button has an id of -1. <p> <p>See also <a href="#find">find</a>(), <a href="#remove">remove</a>() and <a href="#exclusive-prop">exclusive</a>. <p>Examples: <a href="listbox-example.html#x1269">listbox/listbox.cpp</a> and <a href="xform-example.html#x76">xform/xform.cpp</a>. <h3 class=fn>bool <a name="isExclusive"></a>QButtonGroup::isExclusive () const </h3><p>Returns TRUE if the button group is exclusive; otherwise returns FALSE. See the <a href="qbuttongroup.html#exclusive-prop">"exclusive"</a> property for details. <h3 class=fn>bool <a name="isRadioButtonExclusive"></a>QButtonGroup::isRadioButtonExclusive () const </h3><p>Returns TRUE if the radiobuttons in the group are exclusive; otherwise returns FALSE. See the <a href="qbuttongroup.html#radioButtonExclusive-prop">"radioButtonExclusive"</a> property for details. <h3 class=fn>void <a name="moveFocus"></a>QButtonGroup::moveFocus ( int key )<tt> [virtual]</tt> </h3> Moves the <a href="focus.html#keyboard-focus">keyboard focus</a> according to <em>key</em>, and if appropriate checks the new focus item. <p> This function does nothing unless the keyboard focus points to one of the button group members and <em>key</em> is one of <a href="qt.html#Key-enum">Key_Up</a>, <a href="qt.html#Key-enum">Key_Down</a>, <a href="qt.html#Key-enum">Key_Left</a> and <a href="qt.html#Key-enum">Key_Right</a>. <h3 class=fn>void <a name="pressed"></a>QButtonGroup::pressed ( int id )<tt> [signal]</tt> </h3> This signal is emitted when a button in the group is <a href="qbutton.html#pressed">pressed</a>. The <em>id</em> argument is the button's identifier. <h3 class=fn>void <a name="released"></a>QButtonGroup::released ( int id )<tt> [signal]</tt> </h3> This signal is emitted when a button in the group is <a href="qbutton.html#released">released</a>. The <em>id</em> argument is the button's identifier. <h3 class=fn>void <a name="remove"></a>QButtonGroup::remove ( <a href="qbutton.html">QButton</a> * button ) </h3> Removes the <em>button</em> from the button group. <p>See also <a href="#insert">insert</a>(). <h3 class=fn><a href="qbutton.html">QButton</a> * <a name="selected"></a>QButtonGroup::selected () const </h3> Returns a pointer to the selected toggle button if exactly one is selected; returns 0 otherwise. <h3 class=fn>void <a name="setButton"></a>QButtonGroup::setButton ( int id )<tt> [virtual]</tt> </h3> Sets the button with id <em>id</em> to be on; if this is an exclusive group, all other buttons in the group will be set to off. <h3 class=fn>void <a name="setExclusive"></a>QButtonGroup::setExclusive ( bool )<tt> [virtual]</tt> </h3><p>Sets whether the button group is exclusive. See the <a href="qbuttongroup.html#exclusive-prop">"exclusive"</a> property for details. <h3 class=fn>void <a name="setRadioButtonExclusive"></a>QButtonGroup::setRadioButtonExclusive ( bool )<tt> [virtual]</tt> </h3><p>Sets whether the radiobuttons in the group are exclusive. See the <a href="qbuttongroup.html#radioButtonExclusive-prop">"radioButtonExclusive"</a> property for details. <hr><h2>Property Documentation</h2> <h3 class=fn>bool <a name="exclusive-prop"></a>exclusive</h3> <p>This property holds whether the button group is exclusive. <p>If this property is TRUE, then the buttons in the group are toggled, and to untoggle a button you must click on another button in the group. The default value is FALSE. <p>Set this property's value with <a href="#setExclusive">setExclusive</a>() and get this property's value with <a href="#isExclusive">isExclusive</a>(). <h3 class=fn>bool <a name="radioButtonExclusive-prop"></a>radioButtonExclusive</h3> <p>This property holds whether the radiobuttons in the group are exclusive. <p>If this property is TRUE (the default), the radiobuttons in the group are treated exclusively. <p>Set this property's value with <a href="#setRadioButtonExclusive">setRadioButtonExclusive</a>() and get this property's value with <a href="#isRadioButtonExclusive">isRadioButtonExclusive</a>(). <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2001 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>