Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 855

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/widgets/qaction.cpp:1110 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QActionGroup 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&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>QActionGroup Class Reference</h1>

<p>The QActionGroup class groups actions together.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qaction-h.html">qaction.h</a>&gt;</tt>
<p>Inherits <a href="qaction.html">QAction</a>.
<p><a href="qactiongroup-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QActionGroup"><b>QActionGroup</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;exclusive = TRUE )</div></li>
<li><div class=fn><a href="#~QActionGroup"><b>~QActionGroup</b></a> ()</div></li>
<li><div class=fn>void <a href="#setExclusive"><b>setExclusive</b></a> ( bool )</div></li>
<li><div class=fn>bool <a href="#isExclusive"><b>isExclusive</b></a> () const</div></li>
<li><div class=fn>void <a href="#add"><b>add</b></a> ( QAction&nbsp;*&nbsp;action )</div></li>
<li><div class=fn>void <a href="#addSeparator"><b>addSeparator</b></a> ()</div></li>
<li><div class=fn>virtual bool <a href="#addTo"><b>addTo</b></a> ( QWidget&nbsp;*&nbsp;w )</div></li>
<li><div class=fn>void <a href="#setUsesDropDown"><b>setUsesDropDown</b></a> ( bool&nbsp;enable )</div></li>
<li><div class=fn>bool <a href="#usesDropDown"><b>usesDropDown</b></a> () const</div></li>
<li><div class=fn>void insert ( QAction&nbsp;*&nbsp;a ) &nbsp;<em>(obsolete)</em></div></li>
</ul>
<h2>Signals</h2>
<ul>
<li><div class=fn>void <a href="#selected"><b>selected</b></a> ( QAction * )</div></li>
</ul>
<h2>Properties</h2>
<ul>
<li><div class=fn>bool <a href="#exclusive-prop"><b>exclusive</b></a>&nbsp;- whether the action group does exclusive toggling</div></li>
<li><div class=fn>bool <a href="#usesDropDown-prop"><b>usesDropDown</b></a>&nbsp;- whether the group's actions are displayed in a subwidget of the widgets the action group is added to</div></li>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class=fn>virtual void <a href="#addedTo"><b>addedTo</b></a> ( QWidget&nbsp;*&nbsp;actionWidget, QWidget&nbsp;*&nbsp;container, QAction&nbsp;*&nbsp;a )</div></li>
<li><div class=fn>virtual void <a href="#addedTo-2"><b>addedTo</b></a> ( int&nbsp;index, QPopupMenu&nbsp;*&nbsp;menu, QAction&nbsp;*&nbsp;a )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>




<p> The QActionGroup class groups actions together.
<p> In some situations it is useful to group actions together. For
example, if you have a left justify action, a right justify action
and a center action, only one of these actions should be active at
any one time, and one simple way of achieving this is to group the
actions together in an action group and <a href="#setExclusive">setExclusive</a>(TRUE).
<p> An action group can also be added to a menu or a toolbar as a single
unit, with all the actions within the action group appearing as
separate menu options and toolbar buttons.
<p> Here's an example from examples/textedit:


<pre>        QActionGroup *grp = new QActionGroup( this );
    <a name="x18"></a>    grp-&gt;<a href="#setExclusive">setExclusive</a>( TRUE );
    <a name="x17"></a>    <a href="qobject.html#connect">connect</a>( grp, SIGNAL( <a href="#selected">selected</a>( <a href="qaction.html">QAction</a>* ) ), this, SLOT( textAlign( <a href="qaction.html">QAction</a>* ) ) );
</pre>
<p> We create a new action  group, call setExclusive() to ensure that
only one of the actions in the group is ever active at any one time.
We then connect the group to our textAlign() slot.
<p> <pre>        actionAlignLeft = new <a href="qaction.html">QAction</a>( <a href="qobject.html#tr">tr</a>( "Left" ), QPixmap( "textleft.xpm" ), tr( "&amp;Left" ), CTRL + Key_L, grp, "textLeft" );
    <a name="x15"></a>    actionAlignLeft-&gt;<a href="qaction.html#addTo">addTo</a>( tb );
        actionAlignLeft-&gt;<a href="qaction.html#addTo">addTo</a>( menu );
    <a name="x16"></a>    actionAlignLeft-&gt;<a href="qaction.html#setToggleAction">setToggleAction</a>( TRUE );
</pre>
<p> We create a left align action, add it to the toolbar and the menu
and make it a toggle action. We create center and right align
actions in exactly the same way.
<p> 
The actions in an action group emit their <a href="qaction.html#activated">activated</a>()
(and for toggle actions, <a href="qaction.html#toggled">toggled</a>()) signals as usual.
<p> The <a href="#setExclusive">setExclusive</a>() function is used to ensure that only one action
is active at any one time: it should be used with actions which have
their <a href="qaction.html#toggleAction-prop">toggleAction</a> set to TRUE.
<p> Action group actions appear as individual menu options and toolbar
buttons. For exclusive action groups use <a href="#setUsesDropDown">setUsesDropDown</a>() to
display the actions in a subwidget of any widget the action group is
added to. For example, the actions would appear in a combobox in a
toolbar or as a submenu in a menu.
<p> Actions can be added to an action group using <a href="#add">add</a>(), but normally
they are added by creating the action with the action group as
parent. Actions can have separators dividing them using
<a href="#addSeparator">addSeparator</a>(). Action groups are added to widgets with <a href="#addTo">addTo</a>().
<p> <p>See also <a href="application.html">Main Window and Related Classes</a> and <a href="basic.html">Basic Widgets</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QActionGroup"></a>QActionGroup::QActionGroup ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;exclusive = TRUE )
</h3> Constructs an action group with parent <em>parent</em> and name <em>name</em>.
<p> If <em>exclusive</em> is TRUE only one toggle action in the group will
ever be active.
<p> 
<h3 class=fn><a name="~QActionGroup"></a>QActionGroup::~QActionGroup ()
</h3> Destroys the object and frees allocated resources. 
<h3 class=fn>void <a name="add"></a>QActionGroup::add ( <a href="qaction.html">QAction</a>&nbsp;*&nbsp;action )
</h3> Adds action <em>action</em> to this group.
<p> Normally an action is added to a group by creating it with the group
as parent, so this function is not usually used.
<p> <p>See also <a href="#addTo">addTo</a>().

<h3 class=fn>void <a name="addSeparator"></a>QActionGroup::addSeparator ()
</h3> Adds a separator to the group. 
<h3 class=fn>bool <a name="addTo"></a>QActionGroup::addTo ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
</h3>
Adds this action group to the widget <em>w</em>.
<p> If <a href="#usesDropDown">usesDropDown</a>() is TRUE and exclusive is TRUE (see <a href="#setExclusive">setExclusive</a>())
the actions are presented in a combobox if <em>w</em> is a toolbar and as
a submenu if <em>w</em> is a menu. Otherwise (the default) the actions
within the group are added to the widget individually, for example
if the widget is a menu the actions will appear as individual menu
options and if the widget is a toolbar the actions will appear as
toolbar buttons.
<p> It is recommended that actions in action groups, especially where
usesDropDown() is TRUE, have their <a href="qaction.html#menuText">menuText</a>() or <a href="qaction.html#text">text</a>() property set.
<p> All actions should be added to the action group <em>before</em> the action
group is added to the widget. If actions are added to the action
group <em>after</em> the action group has been added to the widget these
later actions will <em>not</em> appear.
<p> <p>See also <a href="#exclusive-prop">exclusive</a>, <a href="#usesDropDown-prop">usesDropDown</a> and <a href="qaction.html#removeFrom">removeFrom</a>().

<p>Examples: <a href="actiongroup-example.html#x2006">action/actiongroup/editor.cpp</a> and <a href="themes-example.html#x335">themes/themes.cpp</a>.
<p>Reimplemented from <a href="qaction.html#addTo">QAction</a>.
<h3 class=fn>void <a name="addedTo"></a>QActionGroup::addedTo ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;actionWidget, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;container, <a href="qaction.html">QAction</a>&nbsp;*&nbsp;a )<tt> [virtual protected]</tt>
</h3> This function is called from the <a href="#addTo">addTo</a>() function when it created
a widget (<em>actionWidget</em>) for the child action <em>a</em> in the <em>container</em>.

<h3 class=fn>void <a name="addedTo-2"></a>QActionGroup::addedTo ( int&nbsp;index, <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;menu, <a href="qaction.html">QAction</a>&nbsp;*&nbsp;a )<tt> [virtual protected]</tt>
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> This function is called from the <a href="#addTo">addTo</a>() function when it created a
menu item for the child action at the index <em>index</em> in the popup
menu <em>menu</em>.

<h3 class=fn>void <a name="insert"></a>QActionGroup::insert ( <a href="qaction.html">QAction</a>&nbsp;*&nbsp;a )
</h3> 
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Use <a href="#add">add</a>() instead, or better still create the action with the action
group as its parent.

<h3 class=fn>bool <a name="isExclusive"></a>QActionGroup::isExclusive () const
</h3><p>Returns TRUE if the action group does exclusive toggling; otherwise returns FALSE.
See the <a href="qactiongroup.html#exclusive-prop">"exclusive"</a> property for details.
<h3 class=fn>void <a name="selected"></a>QActionGroup::selected ( <a href="qaction.html">QAction</a>&nbsp;* )<tt> [signal]</tt>
</h3>

<p> This signal is emitted from exclusive groups when toggle actions
change state.
<p> The argument is the action whose state changed to "on".
<p> 

<pre>        QActionGroup * colors = new QActionGroup( this, "colors", TRUE );
</pre><pre>    <a name="x20"></a><a name="x19"></a>    QObject::<a href="qobject.html#connect">connect</a>( colors, SIGNAL( <a href="#selected">selected</a>( <a href="qaction.html">QAction</a> * ) ),
                          this, SLOT( setFontColor( <a href="qaction.html">QAction</a> * ) ) );
</pre>
<p> In this example we connect the <a href="#selected">selected</a>() signal to our own
setFontColor() slot, passing the <a href="qaction.html">QAction</a> so that we know which
action was chosen by the user.
<p> (See the <a href="actiongroup.html">QActionGroup Walkthrough.</a>)
<p> <p>See also <a href="#exclusive-prop">exclusive</a> and <a href="qaction.html#on-prop">on</a>.

<p>Examples: <a href="qactiongroup.html#x19">action/actiongroup/editor.cpp</a> and <a href="qactiongroup.html#x17">textedit/textedit.cpp</a>.
<h3 class=fn>void <a name="setExclusive"></a>QActionGroup::setExclusive ( bool )
</h3><p>Sets whether the action group does exclusive toggling.
See the <a href="qactiongroup.html#exclusive-prop">"exclusive"</a> property for details.
<h3 class=fn>void <a name="setUsesDropDown"></a>QActionGroup::setUsesDropDown ( bool&nbsp;enable )
</h3><p>Sets whether the group's actions are displayed in a subwidget of the widgets the action group is added to to <em>enable</em>.
See the <a href="qactiongroup.html#usesDropDown-prop">"usesDropDown"</a> property for details.
<h3 class=fn>bool <a name="usesDropDown"></a>QActionGroup::usesDropDown () const
</h3><p>Returns TRUE if the group's actions are displayed in a subwidget of the widgets the action group is added to; otherwise returns FALSE.
See the <a href="qactiongroup.html#usesDropDown-prop">"usesDropDown"</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 action group does exclusive toggling.
<p>If exclusive is TRUE only one toggle action in the action group can
ever be active at any one time. If the user chooses another toggle
action in the group the one they chose becomes active and the one
that was active becomes inactive. By default this property is FALSE.
<p> <p>See also <a href="qaction.html#toggleAction-prop">QAction::toggleAction</a>.

<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="usesDropDown-prop"></a>usesDropDown</h3>  <p>This property holds whether the group's actions are displayed in a subwidget of the widgets the action group is added to.
<p>Exclusive action groups added to a toolbar display their actions in
a combobox with the action's <a href="qaction.html#text-prop">QAction::text</a> and <a href="qaction.html#iconSet-prop">QAction::iconSet</a> properties shown. Non-exclusive groups are
represented by a tool button showing their <a href="qaction.html#iconSet-prop">QAction::iconSet</a> and
-- depending on <a href="qmainwindow.html#usesTextLabel">QMainWindow::usesTextLabel</a>() -- <a href="qaction.html#text">text</a>() property.
<p> In a popup menu the member actions are displayed in a
submenu.
<p> Changing usesDropDown only effects <em>subsequent</em> calls to <a href="#addTo">addTo</a>().
<p> This property's default is FALSE.
<p> 
<p>Set this property's value with <a href="#setUsesDropDown">setUsesDropDown</a>() and get this property's value with <a href="#usesDropDown">usesDropDown</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 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 &copy; 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>