source: trunk/doc/html/qactiongroup.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 13.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qaction.cpp:1375 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QActionGroup Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<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>
33
34<p>The QActionGroup class groups actions together.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qaction-h.html">qaction.h</a>&gt;</tt>
37<p>Inherits <a href="qaction.html">QAction</a>.
38<p><a href="qactiongroup-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QActionGroup"><b>QActionGroup</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
42<li class=fn><a href="#QActionGroup-2"><b>QActionGroup</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name, bool&nbsp;exclusive )</li>
43<li class=fn><a href="#~QActionGroup"><b>~QActionGroup</b></a> ()</li>
44<li class=fn>void <a href="#setExclusive"><b>setExclusive</b></a> ( bool )</li>
45<li class=fn>bool <a href="#isExclusive"><b>isExclusive</b></a> () const</li>
46<li class=fn>void <a href="#add"><b>add</b></a> ( QAction&nbsp;*&nbsp;action )</li>
47<li class=fn>void <a href="#addSeparator"><b>addSeparator</b></a> ()</li>
48<li class=fn>virtual bool <a href="#addTo"><b>addTo</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
49<li class=fn>void <a href="#setUsesDropDown"><b>setUsesDropDown</b></a> ( bool&nbsp;enable )</li>
50<li class=fn>bool <a href="#usesDropDown"><b>usesDropDown</b></a> () const</li>
51<li class=fn>void insert ( QAction&nbsp;*&nbsp;a ) &nbsp;<em>(obsolete)</em></li>
52</ul>
53<h2>Signals</h2>
54<ul>
55<li class=fn>void <a href="#selected"><b>selected</b></a> ( QAction * )</li>
56</ul>
57<h2>Properties</h2>
58<ul>
59<li class=fn>bool <a href="#exclusive-prop"><b>exclusive</b></a>&nbsp;- whether the action group does exclusive toggling</li>
60<li 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</li>
61</ul>
62<hr><a name="details"></a><h2>Detailed Description</h2>
63
64
65The QActionGroup class groups actions together.
66<p>
67
68<p> In some situations it is useful to group actions together. For
69example, if you have a left justify action, a right justify action
70and a center action, only one of these actions should be active at
71any one time, and one simple way of achieving this is to group the
72actions together in an action group.
73<p> An action group can also be added to a menu or a toolbar as a
74single unit, with all the actions within the action group
75appearing as separate menu options and toolbar buttons.
76<p> Here's an example from examples/textedit:
77
78
79<pre> QActionGroup *grp = new QActionGroup( this );
80 <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>* ) ) );
81</pre>
82<p> Here we create a new action group. Since the action group is exclusive
83by default, only one of the actions in the group is ever active at any
84one time. We then connect the group's <a href="#selected">selected</a>() signal to our
85textAlign() slot.
86<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( "&amp;Left" ), CTRL + Key_L, grp, "textLeft" );
87 <a name="x2111"></a> actionAlignLeft-&gt;<a href="qaction.html#setToggleAction">setToggleAction</a>( TRUE );
88</pre>
89<p> We create a left align action, add it to the toolbar and the menu
90and make it a toggle action. We create center and right align
91actions in exactly the same way.
92<p>
93The actions in an action group emit their <a href="qaction.html#activated">activated</a>() (and for
94toggle actions, <a href="qaction.html#toggled">toggled</a>()) signals as usual.
95<p> The <a href="#setExclusive">setExclusive</a>() function is used to ensure that only one action
96is active at any one time: it should be used with actions which
97have their <a href="qaction.html#toggleAction-prop">toggleAction</a> set to TRUE.
98<p> Action group actions appear as individual menu options and toolbar
99buttons. For exclusive action groups use <a href="#setUsesDropDown">setUsesDropDown</a>() to
100display the actions in a subwidget of any widget the action group
101is added to. For example, the actions would appear in a combobox
102in a toolbar or as a submenu in a menu.
103<p> Actions can be added to an action group using <a href="#add">add</a>(), but normally
104they are added by creating the action with the action group as
105parent. Actions can have separators dividing them using
106<a href="#addSeparator">addSeparator</a>(). Action groups are added to widgets with <a href="#addTo">addTo</a>().
107<p>See also <a href="application.html">Main Window and Related Classes</a> and <a href="basic.html">Basic Widgets</a>.
108
109<hr><h2>Member Function Documentation</h2>
110<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 )
111</h3>
112Constructs an action group called <em>name</em>, with parent <em>parent</em>.
113<p> The action group is exclusive by default. Call <a href="#setExclusive">setExclusive</a>(FALSE) to make
114the action group non-exclusive.
115
116<h3 class=fn><a name="QActionGroup-2"></a>QActionGroup::QActionGroup ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name, bool&nbsp;exclusive )
117</h3>
118Constructs an action group called <em>name</em>, with parent <em>parent</em>.
119<p> If <em>exclusive</em> is TRUE only one toggle action in the group will
120ever be active.
121<p> <p>See also <a href="#exclusive-prop">exclusive</a>.
122
123<h3 class=fn><a name="~QActionGroup"></a>QActionGroup::~QActionGroup ()
124</h3>
125Destroys the object and frees allocated resources.
126
127<h3 class=fn>void <a name="add"></a>QActionGroup::add ( <a href="qaction.html">QAction</a>&nbsp;*&nbsp;action )
128</h3>
129Adds action <em>action</em> to this group.
130<p> Normally an action is added to a group by creating it with the
131group as parent, so this function is not usually used.
132<p> <p>See also <a href="#addTo">addTo</a>().
133
134<h3 class=fn>void <a name="addSeparator"></a>QActionGroup::addSeparator ()
135</h3>
136Adds a separator to the group.
137
138<h3 class=fn>bool <a name="addTo"></a>QActionGroup::addTo ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
139</h3>
140Adds this action group to the widget <em>w</em>.
141<p> If <a href="#isExclusive">isExclusive</a>() is FALSE or <a href="#usesDropDown">usesDropDown</a>() is FALSE, the actions within
142the group are added to the widget individually. For example, if the widget
143is a menu, the actions will appear as individual menu options, and
144if the widget is a toolbar, the actions will appear as toolbar buttons.
145<p> If both isExclusive() and usesDropDown() are TRUE, the actions
146are presented either in a combobox (if <em>w</em> is a toolbar) or in a
147submenu (if <em>w</em> is a menu).
148<p> All actions should be added to the action group <em>before</em> the
149action group is added to the widget. If actions are added to the
150action group <em>after</em> the action group has been added to the
151widget these later actions will <em>not</em> appear.
152<p> <p>See also <a href="#exclusive-prop">exclusive</a>, <a href="#usesDropDown-prop">usesDropDown</a>, and <a href="qaction.html#removeFrom">removeFrom</a>().
153
154<p>Example: <a href="themes-example.html#x318">themes/themes.cpp</a>.
155<p>Reimplemented from <a href="qaction.html#addTo">QAction</a>.
156<h3 class=fn>void <a name="insert"></a>QActionGroup::insert ( <a href="qaction.html">QAction</a>&nbsp;*&nbsp;a )
157</h3>
158<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
159<p> Use <a href="#add">add</a>() instead, or better still create the action with the action
160group as its parent.
161
162<h3 class=fn>bool <a name="isExclusive"></a>QActionGroup::isExclusive () const
163</h3><p>Returns TRUE if the action group does exclusive toggling; otherwise returns FALSE.
164See the <a href="qactiongroup.html#exclusive-prop">"exclusive"</a> property for details.
165<h3 class=fn>void <a name="selected"></a>QActionGroup::selected ( <a href="qaction.html">QAction</a>&nbsp;* )<tt> [signal]</tt>
166</h3>
167
168<p> This signal is emitted from exclusive groups when toggle actions
169change state.
170<p> The argument is the action whose state changed to "on".
171<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>().
172
173<p>Examples: <a href="canvas-chart-example.html#x2873">chart/chartform.cpp</a> and <a href="qactiongroup.html#x2112">textedit/textedit.cpp</a>.
174<h3 class=fn>void <a name="setExclusive"></a>QActionGroup::setExclusive ( bool )
175</h3><p>Sets whether the action group does exclusive toggling.
176See the <a href="qactiongroup.html#exclusive-prop">"exclusive"</a> property for details.
177<h3 class=fn>void <a name="setUsesDropDown"></a>QActionGroup::setUsesDropDown ( bool&nbsp;enable )
178</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>.
179See the <a href="qactiongroup.html#usesDropDown-prop">"usesDropDown"</a> property for details.
180<h3 class=fn>bool <a name="usesDropDown"></a>QActionGroup::usesDropDown () const
181</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.
182See the <a href="qactiongroup.html#usesDropDown-prop">"usesDropDown"</a> property for details.
183<hr><h2>Property Documentation</h2>
184<h3 class=fn>bool <a name="exclusive-prop"></a>exclusive</h3>
185<p>This property holds whether the action group does exclusive toggling.
186<p>If exclusive is TRUE only one toggle action in the action group
187can ever be active at any one time. If the user chooses another
188toggle action in the group the one they chose becomes active and
189the one that was active becomes inactive.
190<p> <p>See also <a href="qaction.html#toggleAction-prop">QAction::toggleAction</a>.
191
192<p>Set this property's value with <a href="#setExclusive">setExclusive</a>() and get this property's value with <a href="#isExclusive">isExclusive</a>().
193<h3 class=fn>bool <a name="usesDropDown-prop"></a>usesDropDown</h3>
194<p>This property holds whether the group's actions are displayed in a subwidget of the widgets the action group is added to.
195<p>Exclusive action groups added to a toolbar display their actions
196in 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
197represented by a tool button showing their <a href="qaction.html#iconSet-prop">QAction::iconSet</a> and
198-- depending on <a href="qmainwindow.html#usesTextLabel">QMainWindow::usesTextLabel</a>() -- <a href="qaction.html#text">text</a>()
199property.
200<p> In a popup menu the member actions are displayed in a submenu.
201<p> Changing usesDropDown only affects <em>subsequent</em> calls to <a href="#addTo">addTo</a>().
202<p> Note that setting this property for actions in a combobox causes
203calls to their <a href="qaction.html#setVisible">QAction::setVisible</a>(),
204<a href="qaction.html#setEnabled">QAction::setEnabled</a>(), and
205<a href="qaction.html#setDisabled">QAction::setDisabled</a>() functions to have no effect.
206<p> This property's default is FALSE.
207<p>
208<p>Set this property's value with <a href="#setUsesDropDown">setUsesDropDown</a>() and get this property's value with <a href="#usesDropDown">usesDropDown</a>().
209<!-- eof -->
210<hr><p>
211This file is part of the <a href="index.html">Qt toolkit</a>.
212Copyright &copy; 1995-2007
213<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
214<table width=100% cellspacing=0 border=0><tr>
215<td>Copyright &copy; 2007
216<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
217<td align=right><div align=right>Qt 3.3.8</div>
218</table></div></address></body>
219</html>
Note: See TracBrowser for help on using the repository browser.