source: trunk/doc/html/qaction.html@ 208

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

reference documentation added

File size: 35.2 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:52 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QAction 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>QAction Class Reference</h1>
33
34<p>The QAction class provides an abstract user interface
35action that can appear both in menus and tool bars.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qaction-h.html">qaction.h</a>&gt;</tt>
38<p>Inherits <a href="qobject.html">QObject</a>.
39<p>Inherited by <a href="qactiongroup.html">QActionGroup</a>.
40<p><a href="qaction-members.html">List of all member functions.</a>
41<h2>Public Members</h2>
42<ul>
43<li class=fn><a href="#QAction"><b>QAction</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
44<li class=fn><a href="#QAction-2"><b>QAction</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;menuText, QKeySequence&nbsp;accel, QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
45<li class=fn><a href="#QAction-3"><b>QAction</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;menuText, QKeySequence&nbsp;accel, QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
46<li class=fn>QAction ( const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;menuText, QKeySequence&nbsp;accel, QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;toggle = FALSE ) &nbsp;<em>(obsolete)</em></li>
47<li class=fn>QAction ( const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;menuText, QKeySequence&nbsp;accel, QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;toggle = FALSE ) &nbsp;<em>(obsolete)</em></li>
48<li class=fn>QAction ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name, bool&nbsp;toggle ) &nbsp;<em>(obsolete)</em></li>
49<li class=fn><a href="#~QAction"><b>~QAction</b></a> ()</li>
50<li class=fn>virtual void <a href="#setIconSet"><b>setIconSet</b></a> ( const QIconSet &amp; )</li>
51<li class=fn>QIconSet <a href="#iconSet"><b>iconSet</b></a> () const</li>
52<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString &amp; )</li>
53<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
54<li class=fn>virtual void <a href="#setMenuText"><b>setMenuText</b></a> ( const QString &amp; )</li>
55<li class=fn>QString <a href="#menuText"><b>menuText</b></a> () const</li>
56<li class=fn>virtual void <a href="#setToolTip"><b>setToolTip</b></a> ( const QString &amp; )</li>
57<li class=fn>QString <a href="#toolTip"><b>toolTip</b></a> () const</li>
58<li class=fn>virtual void <a href="#setStatusTip"><b>setStatusTip</b></a> ( const QString &amp; )</li>
59<li class=fn>QString <a href="#statusTip"><b>statusTip</b></a> () const</li>
60<li class=fn>virtual void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( const QString &amp; )</li>
61<li class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> () const</li>
62<li class=fn>virtual void <a href="#setAccel"><b>setAccel</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;key )</li>
63<li class=fn>QKeySequence <a href="#accel"><b>accel</b></a> () const</li>
64<li class=fn>virtual void <a href="#setToggleAction"><b>setToggleAction</b></a> ( bool )</li>
65<li class=fn>bool <a href="#isToggleAction"><b>isToggleAction</b></a> () const</li>
66<li class=fn>bool <a href="#isOn"><b>isOn</b></a> () const</li>
67<li class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</li>
68<li class=fn>bool <a href="#isVisible"><b>isVisible</b></a> () const</li>
69<li class=fn>virtual bool <a href="#addTo"><b>addTo</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
70<li class=fn>virtual bool <a href="#removeFrom"><b>removeFrom</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
71</ul>
72<h2>Public Slots</h2>
73<ul>
74<li class=fn>void <a href="#activate"><b>activate</b></a> ()</li>
75<li class=fn>void <a href="#toggle"><b>toggle</b></a> ()</li>
76<li class=fn>virtual void <a href="#setOn"><b>setOn</b></a> ( bool )</li>
77<li class=fn>virtual void <a href="#setEnabled"><b>setEnabled</b></a> ( bool )</li>
78<li class=fn>void <a href="#setDisabled"><b>setDisabled</b></a> ( bool&nbsp;disable )</li>
79<li class=fn>void <a href="#setVisible"><b>setVisible</b></a> ( bool )</li>
80</ul>
81<h2>Signals</h2>
82<ul>
83<li class=fn>void <a href="#activated"><b>activated</b></a> ()</li>
84<li class=fn>void <a href="#toggled"><b>toggled</b></a> ( bool&nbsp;on )</li>
85</ul>
86<h2>Properties</h2>
87<ul>
88<li class=fn>QKeySequence <a href="#accel-prop"><b>accel</b></a>&nbsp;- the action's accelerator key</li>
89<li class=fn>bool <a href="#enabled-prop"><b>enabled</b></a>&nbsp;- whether the action is enabled</li>
90<li class=fn>QIconSet <a href="#iconSet-prop"><b>iconSet</b></a>&nbsp;- the action's icon</li>
91<li class=fn>QString <a href="#menuText-prop"><b>menuText</b></a>&nbsp;- the action's menu text</li>
92<li class=fn>bool <a href="#on-prop"><b>on</b></a>&nbsp;- whether a toggle action is on</li>
93<li class=fn>QString <a href="#statusTip-prop"><b>statusTip</b></a>&nbsp;- the action's status tip</li>
94<li class=fn>QString <a href="#text-prop"><b>text</b></a>&nbsp;- the action's descriptive text</li>
95<li class=fn>bool <a href="#toggleAction-prop"><b>toggleAction</b></a>&nbsp;- whether the action is a toggle action</li>
96<li class=fn>QString <a href="#toolTip-prop"><b>toolTip</b></a>&nbsp;- the action's tool tip</li>
97<li class=fn>bool <a href="#visible-prop"><b>visible</b></a>&nbsp;- whether the action can be seen (e.g. in menus and toolbars)</li>
98<li class=fn>QString <a href="#whatsThis-prop"><b>whatsThis</b></a>&nbsp;- the action's "What's This?" help text</li>
99</ul>
100<h2>Protected Members</h2>
101<ul>
102<li class=fn>virtual void <a href="#addedTo"><b>addedTo</b></a> ( QWidget&nbsp;*&nbsp;actionWidget, QWidget&nbsp;*&nbsp;container )</li>
103<li class=fn>virtual void <a href="#addedTo-2"><b>addedTo</b></a> ( int&nbsp;index, QPopupMenu&nbsp;*&nbsp;menu )</li>
104</ul>
105<hr><a name="details"></a><h2>Detailed Description</h2>
106
107
108The QAction class provides an abstract user interface
109action that can appear both in menus and tool bars.
110<p>
111
112
113<p> In GUI applications many commands can be invoked via a menu
114option, a toolbar button and a keyboard accelerator. Since the
115same action must be performed regardless of how the action was
116invoked, and since the menu and toolbar should be kept in sync, it
117is useful to represent a command as an <em>action</em>. An action can be
118added to a menu and a toolbar and will automatically keep them in
119sync. For example, if the user presses a Bold toolbar button the
120Bold menu item will automatically be checked.
121<p> A QAction may contain an icon, a menu text, an accelerator, a
122status text, a whats this text and a tool tip. Most of these can
123be set in the constructor. They can also be set independently with
124<a href="#setIconSet">setIconSet</a>(), <a href="#setText">setText</a>(), <a href="#setMenuText">setMenuText</a>(), <a href="#setToolTip">setToolTip</a>(),
125<a href="#setStatusTip">setStatusTip</a>(), <a href="#setWhatsThis">setWhatsThis</a>() and <a href="#setAccel">setAccel</a>().
126<p> An action may be a toggle action e.g. a Bold toolbar button, or a
127command action, e.g. 'Open File' to invoke an open file dialog.
128Toggle actions emit the <a href="#toggled">toggled</a>() signal when their state changes.
129Both command and toggle actions emit the <a href="#activated">activated</a>() signal when
130they are invoked. Use <a href="#setToggleAction">setToggleAction</a>() to set an action's toggled
131status. To see if an action is a toggle action use
132<a href="#isToggleAction">isToggleAction</a>(). A toggle action may be "on", <a href="#isOn">isOn</a>() returns
133TRUE, or "off", isOn() returns FALSE.
134<p> Actions are added to widgets (menus or toolbars) using <a href="#addTo">addTo</a>(),
135and removed using <a href="#removeFrom">removeFrom</a>().
136<p> Once a QAction has been created it should be added to the relevant
137menu and toolbar and then connected to the slot which will perform
138the action. For example:
139<p>
140
141<pre> fileOpenAction = new QAction( QPixmap( fileopen ), "&amp;Open...",
142 CTRL+Key_O, this, "open" );
143 <a href="qobject.html#connect">connect</a>( fileOpenAction, SIGNAL( <a href="#activated">activated</a>() ) , this, SLOT( choose() ) );
144</pre>
145<p> We create a "File Save" action with a menu text of "&Save" and
146<em>Ctrl+S</em> as the keyboard accelerator. We connect the
147fileSaveAction's <a href="#activated">activated</a>() signal to our own save() slot. Note
148that at this point there is no menu or toolbar action, we'll add
149them next:
150<p> <pre> <a href="qtoolbar.html">QToolBar</a> * fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
151</pre><pre> fileSaveAction-&gt;<a href="#addTo">addTo</a>( fileTools );
152</pre><pre> <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
153 <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );
154</pre><pre> fileSaveAction-&gt;<a href="#addTo">addTo</a>( file );
155</pre>
156<p> We create a toolbar and add our fileSaveAction to it. Similarly we
157create a menu, add a top-level menu item, and add our
158fileSaveAction.
159<p> We recommend that actions are created as children of the window
160that they are used in. In most cases actions will be children of
161the application's main window.
162<p> To prevent recursion, don't create an action as a child of a
163widget that the action is later added to.
164<p>See also <a href="application.html">Main Window and Related Classes</a> and <a href="basic.html">Basic Widgets</a>.
165
166<hr><h2>Member Function Documentation</h2>
167<h3 class=fn><a name="QAction"></a>QAction::QAction ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
168</h3>
169Constructs an action called <em>name</em> with parent <em>parent</em>.
170<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the new action inserts itself into
171<em>parent</em>.
172<p> For accelerators and status tips to work, <em>parent</em> must either be
173a widget, or an action group whose parent is a widget.
174<p> <b>Warning:</b> To prevent recursion, don't create an action as a child
175of a widget that the action is later added to.
176
177<h3 class=fn><a name="QAction-2"></a>QAction::QAction ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;menuText, <a href="qkeysequence.html">QKeySequence</a>&nbsp;accel, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
178</h3>
179This constructor results in an icon-less action with the the menu
180text <em>menuText</em> and keyboard accelerator <em>accel</em>. It is a child
181of <em>parent</em> and called <em>name</em>.
182<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
183a member of it.
184<p> For accelerators and status tips to work, <em>parent</em> must either be
185a widget, or an action group whose parent is a widget.
186<p> The action uses a stripped version of <em>menuText</em> (e.g. "&amp;Menu
187Option..." becomes "Menu Option") as descriptive text for
188toolbuttons. You can override this by setting a specific
189description with <a href="#setText">setText</a>(). The same text and <em>accel</em> will be
190used for tool tips and status tips unless you provide text for
191these using <a href="#setToolTip">setToolTip</a>() and <a href="#setStatusTip">setStatusTip</a>().
192<p> Call <a href="#setToggleAction">setToggleAction</a>(TRUE) to make the action a toggle action.
193<p> <b>Warning:</b> To prevent recursion, don't create an action as a child
194of a widget that the action is later added to.
195
196<h3 class=fn><a name="QAction-3"></a>QAction::QAction ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;menuText, <a href="qkeysequence.html">QKeySequence</a>&nbsp;accel, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
197</h3>
198This constructor creates an action with the following properties:
199the icon or iconset <em>icon</em>, the menu text <em>menuText</em> and
200keyboard accelerator <em>accel</em>. It is a child of <em>parent</em> and
201called <em>name</em>.
202<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
203a member of it.
204<p> For accelerators and status tips to work, <em>parent</em> must either be
205a widget, or an action group whose parent is a widget.
206<p> The action uses a stripped version of <em>menuText</em> (e.g. "&amp;Menu
207Option..." becomes "Menu Option") as descriptive text for
208toolbuttons. You can override this by setting a specific
209description with <a href="#setText">setText</a>(). The same text and <em>accel</em> will be
210used for tool tips and status tips unless you provide text for
211these using <a href="#setToolTip">setToolTip</a>() and <a href="#setStatusTip">setStatusTip</a>().
212<p> Call <a href="#setToggleAction">setToggleAction</a>(TRUE) to make the action a toggle action.
213<p> <b>Warning:</b> To prevent recursion, don't create an action as a child
214of a widget that the action is later added to.
215
216<h3 class=fn><a name="QAction-4"></a>QAction::QAction ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;menuText, <a href="qkeysequence.html">QKeySequence</a>&nbsp;accel, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;toggle = FALSE )
217</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
218<p> This constructor creates an action with the following properties:
219the description <em>text</em>, the icon or iconset <em>icon</em>, the menu
220text <em>menuText</em> and keyboard accelerator <em>accel</em>. It is a child
221of <em>parent</em> and called <em>name</em>. If <em>toggle</em> is TRUE the action
222will be a toggle action, otherwise it will be a command action.
223<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
224a member of it.
225<p> For accelerators and status tips to work, <em>parent</em> must either be
226a widget, or an action group whose parent is a widget.
227<p> The <em>text</em> and <em>accel</em> will be used for tool tips and status
228tips unless you provide specific text for these using <a href="#setToolTip">setToolTip</a>()
229and <a href="#setStatusTip">setStatusTip</a>().
230
231<h3 class=fn><a name="QAction-5"></a>QAction::QAction ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;menuText, <a href="qkeysequence.html">QKeySequence</a>&nbsp;accel, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;toggle = FALSE )
232</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
233<p> This constructor results in an icon-less action with the
234description <em>text</em>, the menu text <em>menuText</em> and the keyboard
235accelerator <em>accel</em>. Its parent is <em>parent</em> and it is called <em>name</em>. If <em>toggle</em> is TRUE the action will be a toggle action,
236otherwise it will be a command action.
237<p> The action automatically becomes a member of <em>parent</em> if <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>.
238<p> For accelerators and status tips to work, <em>parent</em> must either be
239a widget, or an action group whose parent is a widget.
240<p> The <em>text</em> and <em>accel</em> will be used for tool tips and status
241tips unless you provide specific text for these using <a href="#setToolTip">setToolTip</a>()
242and <a href="#setStatusTip">setStatusTip</a>().
243
244<h3 class=fn><a name="QAction-6"></a>QAction::QAction ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name, bool&nbsp;toggle )
245</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
246<p> Constructs an action called <em>name</em> with parent <em>parent</em>.
247<p> If <em>toggle</em> is TRUE the action will be a toggle action, otherwise
248it will be a command action.
249<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the new action inserts itself into
250<em>parent</em>.
251<p> For accelerators and status tips to work, <em>parent</em> must either be
252a widget, or an action group whose parent is a widget.
253
254<h3 class=fn><a name="~QAction"></a>QAction::~QAction ()
255</h3>
256Destroys the object and frees allocated resources.
257
258<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QAction::accel () const
259</h3><p>Returns the action's accelerator key.
260See the <a href="qaction.html#accel-prop">"accel"</a> property for details.
261<h3 class=fn>void <a name="activate"></a>QAction::activate ()<tt> [slot]</tt>
262</h3>
263Activates the action and executes all connected slots.
264This only works for actions that are not toggle action.
265<p> <p>See also <a href="#toggle">toggle</a>().
266
267<h3 class=fn>void <a name="activated"></a>QAction::activated ()<tt> [signal]</tt>
268</h3>
269
270<p> This signal is emitted when an action is activated by the user,
271e.g. when the user clicks a menu option or a toolbar button or
272presses an action's accelerator key combination.
273<p> Connect to this signal for command actions. Connect to the
274<a href="#toggled">toggled</a>() signal for toggle actions.
275
276<p>Examples: <a href="qaction-application-example.html#x1123">action/application.cpp</a>, <a href="canvas-chart-example.html#x2869">chart/chartform.cpp</a>, and <a href="themes-example.html#x316">themes/themes.cpp</a>.
277<h3 class=fn>bool <a name="addTo"></a>QAction::addTo ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
278</h3>
279Adds this action to widget <em>w</em>.
280<p> Currently actions may be added to <a href="qtoolbar.html">QToolBar</a> and <a href="qpopupmenu.html">QPopupMenu</a> widgets.
281<p> An action added to a tool bar is automatically displayed as a tool
282button; an action added to a pop up menu appears as a menu option.
283<p> <a href="#addTo">addTo</a>() returns TRUE if the action was added successfully and
284FALSE otherwise. (If <em>w</em> is not a QToolBar or QPopupMenu the
285action will not be added and FALSE will be returned.)
286<p> <p>See also <a href="#removeFrom">removeFrom</a>().
287
288<p>Examples: <a href="qaction-application-example.html#x1124">action/application.cpp</a>, <a href="toggleaction-example.html#x2971">action/toggleaction/toggleaction.cpp</a>, and <a href="canvas-chart-example.html#x2870">chart/chartform.cpp</a>.
289<p>Reimplemented in <a href="qactiongroup.html#addTo">QActionGroup</a>.
290<h3 class=fn>void <a name="addedTo"></a>QAction::addedTo ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;actionWidget, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;container )<tt> [virtual protected]</tt>
291</h3>
292This function is called from the <a href="#addTo">addTo</a>() function when it has
293created a widget (<em>actionWidget</em>) for the action in the <em>container</em>.
294
295<h3 class=fn>void <a name="addedTo-2"></a>QAction::addedTo ( int&nbsp;index, <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;menu )<tt> [virtual protected]</tt>
296</h3>
297This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
298<p> This function is called from the <a href="#addTo">addTo</a>() function when it has
299created a menu item at the index position <em>index</em> in the popup
300menu <em>menu</em>.
301
302<h3 class=fn><a href="qiconset.html">QIconSet</a> <a name="iconSet"></a>QAction::iconSet () const
303</h3><p>Returns the action's icon.
304See the <a href="qaction.html#iconSet-prop">"iconSet"</a> property for details.
305<h3 class=fn>bool <a name="isEnabled"></a>QAction::isEnabled () const
306</h3><p>Returns TRUE if the action is enabled; otherwise returns FALSE.
307See the <a href="qaction.html#enabled-prop">"enabled"</a> property for details.
308<h3 class=fn>bool <a name="isOn"></a>QAction::isOn () const
309</h3><p>Returns TRUE if a toggle action is on; otherwise returns FALSE.
310See the <a href="qaction.html#on-prop">"on"</a> property for details.
311<h3 class=fn>bool <a name="isToggleAction"></a>QAction::isToggleAction () const
312</h3><p>Returns TRUE if the action is a toggle action; otherwise returns FALSE.
313See the <a href="qaction.html#toggleAction-prop">"toggleAction"</a> property for details.
314<h3 class=fn>bool <a name="isVisible"></a>QAction::isVisible () const
315</h3><p>Returns TRUE if the action can be seen (e.g. in menus and toolbars); otherwise returns FALSE.
316See the <a href="qaction.html#visible-prop">"visible"</a> property for details.
317<h3 class=fn><a href="qstring.html">QString</a> <a name="menuText"></a>QAction::menuText () const
318</h3><p>Returns the action's menu text.
319See the <a href="qaction.html#menuText-prop">"menuText"</a> property for details.
320<h3 class=fn>bool <a name="removeFrom"></a>QAction::removeFrom ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
321</h3>
322Removes the action from widget <em>w</em>.
323<p> Returns TRUE if the action was removed successfully; otherwise
324returns FALSE.
325<p> <p>See also <a href="#addTo">addTo</a>().
326
327<h3 class=fn>void <a name="setAccel"></a>QAction::setAccel ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;key )<tt> [virtual]</tt>
328</h3><p>Sets the action's accelerator key to <em>key</em>.
329See the <a href="qaction.html#accel-prop">"accel"</a> property for details.
330<h3 class=fn>void <a name="setDisabled"></a>QAction::setDisabled ( bool&nbsp;disable )<tt> [slot]</tt>
331</h3>
332Disables the action if <em>disable</em> is TRUE; otherwise
333enables the action.
334<p> See the <a href="#enabled-prop">enabled</a> documentation for more information.
335
336<h3 class=fn>void <a name="setEnabled"></a>QAction::setEnabled ( bool )<tt> [virtual slot]</tt>
337</h3><p>Sets whether the action is enabled.
338See the <a href="qaction.html#enabled-prop">"enabled"</a> property for details.
339<h3 class=fn>void <a name="setIconSet"></a>QAction::setIconSet ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp; )<tt> [virtual]</tt>
340</h3><p>Sets the action's icon.
341See the <a href="qaction.html#iconSet-prop">"iconSet"</a> property for details.
342<h3 class=fn>void <a name="setMenuText"></a>QAction::setMenuText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
343</h3><p>Sets the action's menu text.
344See the <a href="qaction.html#menuText-prop">"menuText"</a> property for details.
345<h3 class=fn>void <a name="setOn"></a>QAction::setOn ( bool )<tt> [virtual slot]</tt>
346</h3><p>Sets whether a toggle action is on.
347See the <a href="qaction.html#on-prop">"on"</a> property for details.
348<h3 class=fn>void <a name="setStatusTip"></a>QAction::setStatusTip ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
349</h3><p>Sets the action's status tip.
350See the <a href="qaction.html#statusTip-prop">"statusTip"</a> property for details.
351<h3 class=fn>void <a name="setText"></a>QAction::setText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
352</h3><p>Sets the action's descriptive text.
353See the <a href="qaction.html#text-prop">"text"</a> property for details.
354<h3 class=fn>void <a name="setToggleAction"></a>QAction::setToggleAction ( bool )<tt> [virtual]</tt>
355</h3><p>Sets whether the action is a toggle action.
356See the <a href="qaction.html#toggleAction-prop">"toggleAction"</a> property for details.
357<h3 class=fn>void <a name="setToolTip"></a>QAction::setToolTip ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
358</h3><p>Sets the action's tool tip.
359See the <a href="qaction.html#toolTip-prop">"toolTip"</a> property for details.
360<h3 class=fn>void <a name="setVisible"></a>QAction::setVisible ( bool )<tt> [slot]</tt>
361</h3><p>Sets whether the action can be seen (e.g. in menus and toolbars).
362See the <a href="qaction.html#visible-prop">"visible"</a> property for details.
363<h3 class=fn>void <a name="setWhatsThis"></a>QAction::setWhatsThis ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
364</h3><p>Sets the action's "What's This?" help text.
365See the <a href="qaction.html#whatsThis-prop">"whatsThis"</a> property for details.
366<h3 class=fn><a href="qstring.html">QString</a> <a name="statusTip"></a>QAction::statusTip () const
367</h3><p>Returns the action's status tip.
368See the <a href="qaction.html#statusTip-prop">"statusTip"</a> property for details.
369<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QAction::text () const
370</h3><p>Returns the action's descriptive text.
371See the <a href="qaction.html#text-prop">"text"</a> property for details.
372<h3 class=fn>void <a name="toggle"></a>QAction::toggle ()<tt> [slot]</tt>
373</h3>
374Toggles the state of a toggle action.
375<p> <p>See also <a href="#on-prop">on</a>, <a href="#activate">activate</a>(), <a href="#toggled">toggled</a>(), and <a href="#toggleAction-prop">toggleAction</a>.
376
377<h3 class=fn>void <a name="toggled"></a>QAction::toggled ( bool&nbsp;on )<tt> [signal]</tt>
378</h3>
379
380<p> This signal is emitted when a toggle action changes state; command
381actions and <a href="qactiongroup.html">QActionGroup</a>s don't emit <a href="#toggled">toggled</a>().
382<p> The <em>on</em> argument denotes the new state: If <em>on</em> is TRUE the
383toggle action is switched on, and if <em>on</em> is FALSE the toggle
384action is switched off.
385<p> To trigger a user command depending on whether a toggle action has
386been switched on or off connect it to a slot that takes a bool to
387indicate the state, e.g.
388<p>
389
390<pre> <a href="qmainwindow.html">QMainWindow</a> * window = new <a href="qmainwindow.html">QMainWindow</a>;
391</pre><pre> QAction * labelonoffaction = new QAction( window, "labelonoff" );
392</pre><pre> <a name="x2108"></a> QObject::<a href="qobject.html#connect">connect</a>( labelonoffaction, SIGNAL( <a href="#toggled">toggled</a>( bool ) ),
393 <a name="x2109"></a> window, SLOT( <a href="qmainwindow.html#setUsesTextLabel">setUsesTextLabel</a>( bool ) ) );
394</pre>
395<p> <p>See also <a href="#activated">activated</a>(), <a href="#toggleAction-prop">toggleAction</a>, and <a href="#on-prop">on</a>.
396
397<p>Example: <a href="qaction.html#x2108">action/toggleaction/toggleaction.cpp</a>.
398<h3 class=fn><a href="qstring.html">QString</a> <a name="toolTip"></a>QAction::toolTip () const
399</h3><p>Returns the action's tool tip.
400See the <a href="qaction.html#toolTip-prop">"toolTip"</a> property for details.
401<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QAction::whatsThis () const
402</h3><p>Returns the action's "What's This?" help text.
403See the <a href="qaction.html#whatsThis-prop">"whatsThis"</a> property for details.
404<hr><h2>Property Documentation</h2>
405<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel-prop"></a>accel</h3>
406<p>This property holds the action's accelerator key.
407<p>The keycodes can be found in <a href="qt.html#Key-enum">Qt::Key</a> and <a href="qt.html#Modifier-enum">Qt::Modifier</a>. There
408is no default accelerator key.
409
410<p>Set this property's value with <a href="#setAccel">setAccel</a>() and get this property's value with <a href="#accel">accel</a>().
411<h3 class=fn>bool <a name="enabled-prop"></a>enabled</h3>
412<p>This property holds whether the action is enabled.
413<p>Disabled actions can't be chosen by the user. They don't disappear
414from the menu/tool bar but are displayed in a way which indicates
415that they are unavailable, e.g. they might be displayed grayed
416out.
417<p> What's this? help on disabled actions is still available provided
418the <a href="#whatsThis-prop">QAction::whatsThis</a> property is set.
419
420<p>Set this property's value with <a href="#setEnabled">setEnabled</a>() and get this property's value with <a href="#isEnabled">isEnabled</a>().
421<h3 class=fn><a href="qiconset.html">QIconSet</a> <a name="iconSet-prop"></a>iconSet</h3>
422<p>This property holds the action's icon.
423<p>The icon is used as the tool button icon and in the menu to the
424left of the menu text. There is no default icon.
425<p> If a null icon (<a href="qiconset.html#isNull">QIconSet::isNull</a>() is passed into this function,
426the icon of the action is cleared.
427<p> (See the action/toggleaction/toggleaction.cpp example.)
428<p>
429<p>Set this property's value with <a href="#setIconSet">setIconSet</a>() and get this property's value with <a href="#iconSet">iconSet</a>().
430<h3 class=fn><a href="qstring.html">QString</a> <a name="menuText-prop"></a>menuText</h3>
431<p>This property holds the action's menu text.
432<p>If the action is added to a menu the menu option will consist of
433the icon (if there is one), the menu text and the accelerator (if
434there is one). If the menu text is not explicitly set in the
435constructor or by using <a href="#setMenuText">setMenuText</a>() the action's description
436text will be used as the menu text. There is no default menu text.
437<p> <p>See also <a href="#text-prop">text</a>.
438
439<p>Set this property's value with <a href="#setMenuText">setMenuText</a>() and get this property's value with <a href="#menuText">menuText</a>().
440<h3 class=fn>bool <a name="on-prop"></a>on</h3>
441<p>This property holds whether a toggle action is on.
442<p>This property is always on (TRUE) for command actions and
443<a href="qactiongroup.html">QActionGroup</a>s; <a href="#setOn">setOn</a>() has no effect on them. For action's
444where <a href="#isToggleAction">isToggleAction</a>() is TRUE, this property's default value is
445off (FALSE).
446<p> <p>See also <a href="#toggleAction-prop">toggleAction</a>.
447
448<p>Set this property's value with <a href="#setOn">setOn</a>() and get this property's value with <a href="#isOn">isOn</a>().
449<h3 class=fn><a href="qstring.html">QString</a> <a name="statusTip-prop"></a>statusTip</h3>
450<p>This property holds the action's status tip.
451<p>The statusTip is displayed on all status bars that this action's
452toplevel parent widget provides.
453<p> If no status tip is defined, the action uses the tool tip text.
454<p> There is no default statusTip text.
455<p> <p>See also <a href="#statusTip-prop">statusTip</a> and <a href="#toolTip-prop">toolTip</a>.
456
457<p>Set this property's value with <a href="#setStatusTip">setStatusTip</a>() and get this property's value with <a href="#statusTip">statusTip</a>().
458<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
459<p>This property holds the action's descriptive text.
460<p>If <a href="qmainwindow.html#usesTextLabel-prop">QMainWindow::usesTextLabel</a> is TRUE, the text appears as a
461label in the relevant tool button. It also serves as the default
462text in menus and tool tips if these have not been specifically
463defined. There is no default text.
464<p> <p>See also <a href="#menuText-prop">menuText</a>, <a href="#toolTip-prop">toolTip</a>, and <a href="#statusTip-prop">statusTip</a>.
465
466<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
467<h3 class=fn>bool <a name="toggleAction-prop"></a>toggleAction</h3>
468<p>This property holds whether the action is a toggle action.
469<p>A toggle action is one which has an on/off state. For example a
470Bold toolbar button is either on or off. An action which is not a
471toggle action is a command action; a command action is simply
472executed, e.g. file save. This property's default is FALSE.
473<p> In some situations, the state of one toggle action should depend
474on the state of others. For example, "Left Align", "Center" and
475"Right Align" toggle actions are mutually exclusive. To achieve
476exclusive toggling, add the relevant toggle actions to a
477<a href="qactiongroup.html">QActionGroup</a> with the <a href="qactiongroup.html#exclusive-prop">QActionGroup::exclusive</a> property set to
478TRUE.
479
480<p>Set this property's value with <a href="#setToggleAction">setToggleAction</a>() and get this property's value with <a href="#isToggleAction">isToggleAction</a>().
481<h3 class=fn><a href="qstring.html">QString</a> <a name="toolTip-prop"></a>toolTip</h3>
482<p>This property holds the action's tool tip.
483<p>This text is used for the tool tip. If no status tip has been set
484the tool tip will be used for the status tip.
485<p> If no tool tip is specified the action's text is used, and if that
486hasn't been specified the description text is used as the tool tip
487text.
488<p> There is no default tool tip text.
489<p> <p>See also <a href="#statusTip-prop">statusTip</a> and <a href="#accel-prop">accel</a>.
490
491<p>Set this property's value with <a href="#setToolTip">setToolTip</a>() and get this property's value with <a href="#toolTip">toolTip</a>().
492<h3 class=fn>bool <a name="visible-prop"></a>visible</h3>
493<p>This property holds whether the action can be seen (e.g. in menus and toolbars).
494<p>If <em>visible</em> is TRUE the action can be seen (e.g. in menus and
495toolbars) and chosen by the user; if <em>visible</em> is FALSE the
496action cannot be seen or chosen by the user.
497<p> Actions which are not visible are <em>not</em> grayed out; they do not
498appear at all.
499
500<p>Set this property's value with <a href="#setVisible">setVisible</a>() and get this property's value with <a href="#isVisible">isVisible</a>().
501<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis-prop"></a>whatsThis</h3>
502<p>This property holds the action's "What's This?" help text.
503<p>The whats this text is used to provide a brief description of the
504action. The text may contain rich text (HTML-like tags -- see
505<a href="qstylesheet.html">QStyleSheet</a> for the list of supported tags). There is no default
506"What's This" text.
507<p> <p>See also <a href="qwhatsthis.html">QWhatsThis</a>.
508
509<p>Set this property's value with <a href="#setWhatsThis">setWhatsThis</a>() and get this property's value with <a href="#whatsThis">whatsThis</a>().
510<!-- eof -->
511<hr><p>
512This file is part of the <a href="index.html">Qt toolkit</a>.
513Copyright &copy; 1995-2007
514<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
515<table width=100% cellspacing=0 border=0><tr>
516<td>Copyright &copy; 2007
517<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
518<td align=right><div align=right>Qt 3.3.8</div>
519</table></div></address></body>
520</html>
Note: See TracBrowser for help on using the repository browser.