<!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/qaction.cpp:1375 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QActionGroup 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 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>QActionGroup Class Reference</h1> <p>The QActionGroup class groups actions together. <a href="#details">More...</a> <p><tt>#include <<a href="qaction-h.html">qaction.h</a>></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 class=fn><a href="#QActionGroup"><b>QActionGroup</b></a> ( QObject * parent, const char * name = 0 )</li> <li class=fn><a href="#QActionGroup-2"><b>QActionGroup</b></a> ( QObject * parent, const char * name, bool exclusive )</li> <li class=fn><a href="#~QActionGroup"><b>~QActionGroup</b></a> ()</li> <li class=fn>void <a href="#setExclusive"><b>setExclusive</b></a> ( bool )</li> <li class=fn>bool <a href="#isExclusive"><b>isExclusive</b></a> () const</li> <li class=fn>void <a href="#add"><b>add</b></a> ( QAction * action )</li> <li class=fn>void <a href="#addSeparator"><b>addSeparator</b></a> ()</li> <li class=fn>virtual bool <a href="#addTo"><b>addTo</b></a> ( QWidget * w )</li> <li class=fn>void <a href="#setUsesDropDown"><b>setUsesDropDown</b></a> ( bool enable )</li> <li class=fn>bool <a href="#usesDropDown"><b>usesDropDown</b></a> () const</li> <li class=fn>void insert ( QAction * a ) <em>(obsolete)</em></li> </ul> <h2>Signals</h2> <ul> <li class=fn>void <a href="#selected"><b>selected</b></a> ( QAction * )</li> </ul> <h2>Properties</h2> <ul> <li class=fn>bool <a href="#exclusive-prop"><b>exclusive</b></a> - whether the action group does exclusive toggling</li> <li class=fn>bool <a href="#usesDropDown-prop"><b>usesDropDown</b></a> - whether the group's actions are displayed in a subwidget of the widgets the action group is added to</li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QActionGroup class groups actions together. <p> <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. <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="x2112"></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> Here we create a new action group. Since the action group is exclusive by default, only one of the actions in the group is ever active at any one time. We then connect the group's <a href="#selected">selected</a>() signal to our textAlign() slot. <p> <pre> <a name="x2113"></a> actionAlignLeft = new <a href="qaction.html">QAction</a>( QPixmap::<a href="qpixmap.html#fromMimeSource">fromMimeSource</a>( "textleft.xpm" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" ); <a name="x2111"></a> actionAlignLeft-><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>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> * parent, const char * name = 0 ) </h3> Constructs an action group called <em>name</em>, with parent <em>parent</em>. <p> The action group is exclusive by default. Call <a href="#setExclusive">setExclusive</a>(FALSE) to make the action group non-exclusive. <h3 class=fn><a name="QActionGroup-2"></a>QActionGroup::QActionGroup ( <a href="qobject.html">QObject</a> * parent, const char * name, bool exclusive ) </h3> Constructs an action group called <em>name</em>, with parent <em>parent</em>. <p> If <em>exclusive</em> is TRUE only one toggle action in the group will ever be active. <p> <p>See also <a href="#exclusive-prop">exclusive</a>. <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> * 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> * w )<tt> [virtual]</tt> </h3> Adds this action group to the widget <em>w</em>. <p> If <a href="#isExclusive">isExclusive</a>() is FALSE or <a href="#usesDropDown">usesDropDown</a>() is FALSE, 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> If both isExclusive() and usesDropDown() are TRUE, the actions are presented either in a combobox (if <em>w</em> is a toolbar) or in a submenu (if <em>w</em> is a menu). <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>Example: <a href="themes-example.html#x318">themes/themes.cpp</a>. <p>Reimplemented from <a href="qaction.html#addTo">QAction</a>. <h3 class=fn>void <a name="insert"></a>QActionGroup::insert ( <a href="qaction.html">QAction</a> * 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> * )<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> <p>See also <a href="#exclusive-prop">exclusive</a>, <a href="qaction.html#on-prop">on</a>, and <a href="qaction.html#toggled">QAction::toggled</a>(). <p>Examples: <a href="canvas-chart-example.html#x2873">chart/chartform.cpp</a> and <a href="qactiongroup.html#x2112">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 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. <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 affects <em>subsequent</em> calls to <a href="#addTo">addTo</a>(). <p> Note that setting this property for actions in a combobox causes calls to their <a href="qaction.html#setVisible">QAction::setVisible</a>(), <a href="qaction.html#setEnabled">QAction::setEnabled</a>(), and <a href="qaction.html#setDisabled">QAction::setDisabled</a>() functions to have no effect. <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 © 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 © 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>