You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qt3/doc/html/qbuttongroup.html

265 lines
16 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qbuttongroup.cpp:47 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QButtonGroup Class</title>
<style type="text/css"><!--
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&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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 &lt;<a href="qbuttongroup-h.html">qbuttongroup.h</a>&gt;</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 class=fn><a href="#QButtonGroup"><b>QButtonGroup</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#QButtonGroup-2"><b>QButtonGroup</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;title, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#QButtonGroup-3"><b>QButtonGroup</b></a> ( int&nbsp;strips, Orientation&nbsp;orientation, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#QButtonGroup-4"><b>QButtonGroup</b></a> ( int&nbsp;strips, Orientation&nbsp;orientation, const&nbsp;QString&nbsp;&amp;&nbsp;title, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn>bool <a href="#isExclusive"><b>isExclusive</b></a> () const</li>
<li class=fn>bool <a href="#isRadioButtonExclusive"><b>isRadioButtonExclusive</b></a> () const</li>
<li class=fn>virtual void <a href="#setExclusive"><b>setExclusive</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setRadioButtonExclusive"><b>setRadioButtonExclusive</b></a> ( bool )</li>
<li class=fn>int <a href="#insert"><b>insert</b></a> ( QButton&nbsp;*&nbsp;button, int&nbsp;id = -1 )</li>
<li class=fn>void <a href="#remove"><b>remove</b></a> ( QButton&nbsp;*&nbsp;button )</li>
<li class=fn>QButton * <a href="#find"><b>find</b></a> ( int&nbsp;id ) const</li>
<li class=fn>int <a href="#id"><b>id</b></a> ( QButton&nbsp;*&nbsp;button ) const</li>
<li class=fn>int <a href="#count"><b>count</b></a> () const</li>
<li class=fn>virtual void <a href="#setButton"><b>setButton</b></a> ( int&nbsp;id )</li>
<li class=fn>virtual void <a href="#moveFocus"><b>moveFocus</b></a> ( int&nbsp;key )</li>
<li class=fn>QButton * <a href="#selected"><b>selected</b></a> () const</li>
<li class=fn>int <a href="#selectedId"><b>selectedId</b></a> () const</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#pressed"><b>pressed</b></a> ( int&nbsp;id )</li>
<li class=fn>void <a href="#released"><b>released</b></a> ( int&nbsp;id )</li>
<li class=fn>void <a href="#clicked"><b>clicked</b></a> ( int&nbsp;id )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>bool <a href="#exclusive-prop"><b>exclusive</b></a>&nbsp;- whether the button group is exclusive</li>
<li class=fn>bool <a href="#radioButtonExclusive-prop"><b>radioButtonExclusive</b></a>&nbsp;- whether the radio buttons in the group are exclusive</li>
<li class=fn>int <a href="#selectedId-prop"><b>selectedId</b></a>&nbsp;- the selected toggle button</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 a button in the group is clicked. This makes a button group
particularly useful when you have several similar buttons and want
to connect all their clicked() signals to a single 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. Note that all radio buttons
that are inserted into a button group are 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 the 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. In this usage, each button
must be manually inserted, using <a href="#insert">insert</a>(), into the button group
and given 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 <em>on</em> 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="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>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;title, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;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&nbsp;strips, <a href="qt.html#Orientation-enum">Orientation</a>&nbsp;orientation, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;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&nbsp;strips, <a href="qt.html#Orientation-enum">Orientation</a>&nbsp;orientation, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;title, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;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&nbsp;id )<tt> [signal]</tt>
</h3>
<p> This signal is emitted when a button in the group is <a href="qbutton.html#clicked">clicked</a>. The <em>id</em> argument is the
button's identifier.
<p> <p>See also <a href="#insert">insert</a>().
<p>Examples: <a href="drawdemo-example.html#x1062">drawdemo/drawdemo.cpp</a> and <a href="xform-example.html#x1221">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>&nbsp;* <a name="find"></a>QButtonGroup::find ( int&nbsp;id ) const
</h3>
Returns the button with the specified identifier <em>id</em>, or 0 if
the button was not found.
<h3 class=fn>int <a name="id"></a>QButtonGroup::id ( <a href="qbutton.html">QButton</a>&nbsp;*&nbsp;button ) const
</h3>
Returns the id of <em>button</em>, or -1 if <em>button</em> is not a member of
this group.
<p> <p>See also <a href="#selectedId-prop">selectedId</a>.
<h3 class=fn>int <a name="insert"></a>QButtonGroup::insert ( <a href="qbutton.html">QButton</a>&nbsp;*&nbsp;button, int&nbsp;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
passing 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., or if you want the buttons to have some other parent.
<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 &lt;= -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#x1428">listbox/listbox.cpp</a> and <a href="xform-example.html#x1222">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 radio buttons 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&nbsp;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&nbsp;id )<tt> [signal]</tt>
</h3>
<p> 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.
<p> <p>See also <a href="#insert">insert</a>().
<h3 class=fn>void <a name="released"></a>QButtonGroup::released ( int&nbsp;id )<tt> [signal]</tt>
</h3>
<p> 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.
<p> <p>See also <a href="#insert">insert</a>().
<h3 class=fn>void <a name="remove"></a>QButtonGroup::remove ( <a href="qbutton.html">QButton</a>&nbsp;*&nbsp;button )
</h3>
Removes the <em>button</em> from the button group.
<p> <p>See also <a href="#insert">insert</a>().
<h3 class=fn><a href="qbutton.html">QButton</a>&nbsp;* <a name="selected"></a>QButtonGroup::selected () const
</h3>
Returns the selected toggle button if exactly one is selected;
otherwise returns 0.
<p> <p>See also <a href="#selectedId-prop">selectedId</a>.
<h3 class=fn>int <a name="selectedId"></a>QButtonGroup::selectedId () const
</h3><p>Returns the selected toggle button.
See the <a href="qbuttongroup.html#selectedId-prop">"selectedId"</a> property for details.
<h3 class=fn>void <a name="setButton"></a>QButtonGroup::setButton ( int&nbsp;id )<tt> [virtual]</tt>
</h3><p>Sets the selected toggle button to <em>id</em>.
See the <a href="qbuttongroup.html#selectedId-prop">"selectedId"</a> property for details.
<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 radio buttons 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 radio buttons in the group are exclusive.
<p>If this property is TRUE (the default), the <a href="qradiobutton.html">radiobuttons</a> 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>().
<h3 class=fn>int <a name="selectedId-prop"></a>selectedId</h3>
<p>This property holds the selected toggle button.
<p>The toggle button is specified as an ID.
<p> If no toggle button is selected, this property holds -1.
<p> If <a href="#setButton">setButton</a>() is called on an exclusive group, the button with
the given id will be set to on and all the others will be set to
off.
<p> <p>See also <a href="#selected">selected</a>().
<p>Set this property's value with <a href="#setButton">setButton</a>() and get this property's value with <a href="#selectedId">selectedId</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<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 &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>