summaryrefslogtreecommitdiffstats
path: root/doc/html/qaction.html
blob: 51db1eb4a395d08e9f2ab066764c5616c2c0d09b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
<!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:52 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QAction 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>QAction Class Reference</h1>

<p>The QAction class provides an abstract user interface
action that can appear both in menus and tool bars.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qaction-h.html">qaction.h</a>&gt;</tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p>Inherited by <a href="qactiongroup.html">QActionGroup</a>.
<p><a href="qaction-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QAction"><b>QAction</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<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>
<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>
<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>
<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>
<li class=fn>QAction ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name, bool&nbsp;toggle ) &nbsp;<em>(obsolete)</em></li>
<li class=fn><a href="#~QAction"><b>~QAction</b></a> ()</li>
<li class=fn>virtual void <a href="#setIconSet"><b>setIconSet</b></a> ( const QIconSet &amp; )</li>
<li class=fn>QIconSet <a href="#iconSet"><b>iconSet</b></a> () const</li>
<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString &amp; )</li>
<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
<li class=fn>virtual void <a href="#setMenuText"><b>setMenuText</b></a> ( const QString &amp; )</li>
<li class=fn>QString <a href="#menuText"><b>menuText</b></a> () const</li>
<li class=fn>virtual void <a href="#setToolTip"><b>setToolTip</b></a> ( const QString &amp; )</li>
<li class=fn>QString <a href="#toolTip"><b>toolTip</b></a> () const</li>
<li class=fn>virtual void <a href="#setStatusTip"><b>setStatusTip</b></a> ( const QString &amp; )</li>
<li class=fn>QString <a href="#statusTip"><b>statusTip</b></a> () const</li>
<li class=fn>virtual void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( const QString &amp; )</li>
<li class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> () const</li>
<li class=fn>virtual void <a href="#setAccel"><b>setAccel</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;key )</li>
<li class=fn>QKeySequence <a href="#accel"><b>accel</b></a> () const</li>
<li class=fn>virtual void <a href="#setToggleAction"><b>setToggleAction</b></a> ( bool )</li>
<li class=fn>bool <a href="#isToggleAction"><b>isToggleAction</b></a> () const</li>
<li class=fn>bool <a href="#isOn"><b>isOn</b></a> () const</li>
<li class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</li>
<li class=fn>bool <a href="#isVisible"><b>isVisible</b></a> () const</li>
<li class=fn>virtual bool <a href="#addTo"><b>addTo</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
<li class=fn>virtual bool <a href="#removeFrom"><b>removeFrom</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>void <a href="#activate"><b>activate</b></a> ()</li>
<li class=fn>void <a href="#toggle"><b>toggle</b></a> ()</li>
<li class=fn>virtual void <a href="#setOn"><b>setOn</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setEnabled"><b>setEnabled</b></a> ( bool )</li>
<li class=fn>void <a href="#setDisabled"><b>setDisabled</b></a> ( bool&nbsp;disable )</li>
<li class=fn>void <a href="#setVisible"><b>setVisible</b></a> ( bool )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#activated"><b>activated</b></a> ()</li>
<li class=fn>void <a href="#toggled"><b>toggled</b></a> ( bool&nbsp;on )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>QKeySequence <a href="#accel-prop"><b>accel</b></a>&nbsp;- the action's accelerator key</li>
<li class=fn>bool <a href="#enabled-prop"><b>enabled</b></a>&nbsp;- whether the action is enabled</li>
<li class=fn>QIconSet <a href="#iconSet-prop"><b>iconSet</b></a>&nbsp;- the action's icon</li>
<li class=fn>QString <a href="#menuText-prop"><b>menuText</b></a>&nbsp;- the action's menu text</li>
<li class=fn>bool <a href="#on-prop"><b>on</b></a>&nbsp;- whether a toggle action is on</li>
<li class=fn>QString <a href="#statusTip-prop"><b>statusTip</b></a>&nbsp;- the action's status tip</li>
<li class=fn>QString <a href="#text-prop"><b>text</b></a>&nbsp;- the action's descriptive text</li>
<li class=fn>bool <a href="#toggleAction-prop"><b>toggleAction</b></a>&nbsp;- whether the action is a toggle action</li>
<li class=fn>QString <a href="#toolTip-prop"><b>toolTip</b></a>&nbsp;- the action's tool tip</li>
<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>
<li class=fn>QString <a href="#whatsThis-prop"><b>whatsThis</b></a>&nbsp;- the action's "What's This?" help text</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#addedTo"><b>addedTo</b></a> ( QWidget&nbsp;*&nbsp;actionWidget, QWidget&nbsp;*&nbsp;container )</li>
<li class=fn>virtual void <a href="#addedTo-2"><b>addedTo</b></a> ( int&nbsp;index, QPopupMenu&nbsp;*&nbsp;menu )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QAction class provides an abstract user interface
action that can appear both in menus and tool bars.
<p> 


<p> In GUI applications many commands can be invoked via a menu
option, a toolbar button and a keyboard accelerator. Since the
same action must be performed regardless of how the action was
invoked, and since the menu and toolbar should be kept in sync, it
is useful to represent a command as an <em>action</em>. An action can be
added to a menu and a toolbar and will automatically keep them in
sync. For example, if the user presses a Bold toolbar button the
Bold menu item will automatically be checked.
<p> A QAction may contain an icon, a menu text, an accelerator, a
status text, a whats this text and a tool tip. Most of these can
be set in the constructor. They can also be set independently with
<a href="#setIconSet">setIconSet</a>(), <a href="#setText">setText</a>(), <a href="#setMenuText">setMenuText</a>(), <a href="#setToolTip">setToolTip</a>(),
<a href="#setStatusTip">setStatusTip</a>(), <a href="#setWhatsThis">setWhatsThis</a>() and <a href="#setAccel">setAccel</a>().
<p> An action may be a toggle action e.g. a Bold toolbar button, or a
command action, e.g. 'Open File' to invoke an open file dialog.
Toggle actions emit the <a href="#toggled">toggled</a>() signal when their state changes.
Both command and toggle actions emit the <a href="#activated">activated</a>() signal when
they are invoked. Use <a href="#setToggleAction">setToggleAction</a>() to set an action's toggled
status. To see if an action is a toggle action use
<a href="#isToggleAction">isToggleAction</a>(). A toggle action may be "on", <a href="#isOn">isOn</a>() returns
TRUE, or "off", isOn() returns FALSE.
<p> Actions are added to widgets (menus or toolbars) using <a href="#addTo">addTo</a>(),
and removed using <a href="#removeFrom">removeFrom</a>().
<p> Once a QAction has been created it should be added to the relevant
menu and toolbar and then connected to the slot which will perform
the action. For example:
<p> 

<pre>        fileOpenAction = new QAction( QPixmap( fileopen ), "&amp;Open...",
                                      CTRL+Key_O, this, "open" );
        <a href="qobject.html#connect">connect</a>( fileOpenAction, SIGNAL( <a href="#activated">activated</a>() ) , this, SLOT( choose() ) );
</pre>
<p> We create a "File Save" action with a menu text of "&Save" and
<em>Ctrl+S</em> as the keyboard accelerator. We connect the
fileSaveAction's <a href="#activated">activated</a>() signal to our own save() slot. Note
that at this point there is no menu or toolbar action, we'll add
them next:
<p> <pre>        <a href="qtoolbar.html">QToolBar</a> * fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
</pre><pre>        fileSaveAction-&gt;<a href="#addTo">addTo</a>( fileTools );
</pre><pre>        <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
        <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );
</pre><pre>        fileSaveAction-&gt;<a href="#addTo">addTo</a>( file );
</pre>
<p> We create a toolbar and add our fileSaveAction to it. Similarly we
create a menu, add a top-level menu item, and add our
fileSaveAction.
<p> We recommend that actions are created as children of the window
that they are used in. In most cases actions will be children of
the application's main window.
<p> To prevent recursion, don't create an action as a child of a
widget that the action is later added to.
<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="QAction"></a>QAction::QAction ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs an action called <em>name</em> with parent <em>parent</em>.
<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the new action inserts itself into
<em>parent</em>.
<p> For accelerators and status tips to work, <em>parent</em> must either be
a widget, or an action group whose parent is a widget.
<p> <b>Warning:</b> To prevent recursion, don't create an action as a child
of a widget that the action is later added to.

<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 )
</h3>
This constructor results in an icon-less action with the the menu
text <em>menuText</em> and keyboard accelerator <em>accel</em>. It is a child
of <em>parent</em> and called <em>name</em>.
<p> If  <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
a member of it.
<p> For accelerators and status tips to work, <em>parent</em> must either be
a widget, or an action group whose parent is a widget.
<p> The action uses a stripped version of <em>menuText</em> (e.g. "&amp;Menu
Option..." becomes "Menu Option") as descriptive text for
toolbuttons. You can override this by setting a specific
description with <a href="#setText">setText</a>(). The same text and <em>accel</em> will be
used for tool tips and status tips unless you provide text for
these using <a href="#setToolTip">setToolTip</a>() and <a href="#setStatusTip">setStatusTip</a>().
<p> Call <a href="#setToggleAction">setToggleAction</a>(TRUE) to make the action a toggle action.
<p> <b>Warning:</b> To prevent recursion, don't create an action as a child
of a widget that the action is later added to.

<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 )
</h3>
This constructor creates an action with the following properties:
the icon or iconset <em>icon</em>, the menu text <em>menuText</em> and
keyboard accelerator <em>accel</em>. It is a child of <em>parent</em> and
called <em>name</em>.
<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
a member of it.
<p> For accelerators and status tips to work, <em>parent</em> must either be
a widget, or an action group whose parent is a widget.
<p> The action uses a stripped version of <em>menuText</em> (e.g. "&amp;Menu
Option..." becomes "Menu Option") as descriptive text for
toolbuttons. You can override this by setting a specific
description with <a href="#setText">setText</a>(). The same text and <em>accel</em> will be
used for tool tips and status tips unless you provide text for
these using <a href="#setToolTip">setToolTip</a>() and <a href="#setStatusTip">setStatusTip</a>().
<p> Call <a href="#setToggleAction">setToggleAction</a>(TRUE) to make the action a toggle action.
<p> <b>Warning:</b> To prevent recursion, don't create an action as a child
of a widget that the action is later added to.

<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 )
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> This constructor creates an action with the following properties:
the description <em>text</em>, the icon or iconset <em>icon</em>, the menu
text <em>menuText</em> and keyboard accelerator <em>accel</em>. It is a child
of <em>parent</em> and called <em>name</em>. If <em>toggle</em> is TRUE the action
will be a toggle action, otherwise it will be a command action.
<p> If  <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
a member of it.
<p> For accelerators and status tips to work, <em>parent</em> must either be
a widget, or an action group whose parent is a widget.
<p> The <em>text</em> and <em>accel</em> will be used for tool tips and status
tips unless you provide specific text for these using <a href="#setToolTip">setToolTip</a>()
and <a href="#setStatusTip">setStatusTip</a>().

<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 )
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> This constructor results in an icon-less action with the
description <em>text</em>, the menu text <em>menuText</em> and the keyboard
accelerator <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,
otherwise it will be a command action.
<p> The action automatically becomes a member of <em>parent</em> if <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>.
<p> For accelerators and status tips to work, <em>parent</em> must either be
a widget, or an action group whose parent is a widget.
<p> The <em>text</em> and <em>accel</em> will be used for tool tips and status
tips unless you provide specific text for these using <a href="#setToolTip">setToolTip</a>()
and <a href="#setStatusTip">setStatusTip</a>().

<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 )
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Constructs an action called <em>name</em> with parent <em>parent</em>.
<p> If <em>toggle</em> is TRUE the action will be a toggle action, otherwise
it will be a command action.
<p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the new action inserts itself into
<em>parent</em>.
<p> For accelerators and status tips to work, <em>parent</em> must either be
a widget, or an action group whose parent is a widget.

<h3 class=fn><a name="~QAction"></a>QAction::~QAction ()
</h3>
Destroys the object and frees allocated resources.

<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QAction::accel () const
</h3><p>Returns the action's accelerator key.
See the <a href="qaction.html#accel-prop">"accel"</a> property for details.
<h3 class=fn>void <a name="activate"></a>QAction::activate ()<tt> [slot]</tt>
</h3>
Activates the action and executes all connected slots.
This only works for actions that are not toggle action.
<p> <p>See also <a href="#toggle">toggle</a>().

<h3 class=fn>void <a name="activated"></a>QAction::activated ()<tt> [signal]</tt>
</h3>

<p> This signal is emitted when an action is activated by the user,
e.g. when the user clicks a menu option or a toolbar button or
presses an action's accelerator key combination.
<p> Connect to this signal for command actions. Connect to the
<a href="#toggled">toggled</a>() signal for toggle actions.

<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>.
<h3 class=fn>bool <a name="addTo"></a>QAction::addTo ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
</h3>
Adds this action to widget <em>w</em>.
<p> Currently actions may be added to <a href="qtoolbar.html">QToolBar</a> and <a href="qpopupmenu.html">QPopupMenu</a> widgets.
<p> An action added to a tool bar is automatically displayed as a tool
button; an action added to a pop up menu appears as a menu option.
<p> <a href="#addTo">addTo</a>() returns TRUE if the action was added successfully and
FALSE otherwise. (If <em>w</em> is not a QToolBar or QPopupMenu the
action will not be added and FALSE will be returned.)
<p> <p>See also <a href="#removeFrom">removeFrom</a>().

<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>.
<p>Reimplemented in <a href="qactiongroup.html#addTo">QActionGroup</a>.
<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>
</h3>
This function is called from the <a href="#addTo">addTo</a>() function when it has
created a widget (<em>actionWidget</em>) for the action in the <em>container</em>.

<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>
</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 has
created a menu item at the index position <em>index</em> in the popup
menu <em>menu</em>.

<h3 class=fn><a href="qiconset.html">QIconSet</a> <a name="iconSet"></a>QAction::iconSet () const
</h3><p>Returns the action's icon.
See the <a href="qaction.html#iconSet-prop">"iconSet"</a> property for details.
<h3 class=fn>bool <a name="isEnabled"></a>QAction::isEnabled () const
</h3><p>Returns TRUE if the action is enabled; otherwise returns FALSE.
See the <a href="qaction.html#enabled-prop">"enabled"</a> property for details.
<h3 class=fn>bool <a name="isOn"></a>QAction::isOn () const
</h3><p>Returns TRUE if a toggle action is on; otherwise returns FALSE.
See the <a href="qaction.html#on-prop">"on"</a> property for details.
<h3 class=fn>bool <a name="isToggleAction"></a>QAction::isToggleAction () const
</h3><p>Returns TRUE if the action is a toggle action; otherwise returns FALSE.
See the <a href="qaction.html#toggleAction-prop">"toggleAction"</a> property for details.
<h3 class=fn>bool <a name="isVisible"></a>QAction::isVisible () const
</h3><p>Returns TRUE if the action can be seen (e.g. in menus and toolbars); otherwise returns FALSE.
See the <a href="qaction.html#visible-prop">"visible"</a> property for details.
<h3 class=fn><a href="qstring.html">QString</a> <a name="menuText"></a>QAction::menuText () const
</h3><p>Returns the action's menu text.
See the <a href="qaction.html#menuText-prop">"menuText"</a> property for details.
<h3 class=fn>bool <a name="removeFrom"></a>QAction::removeFrom ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
</h3>
Removes the action from widget <em>w</em>.
<p> Returns TRUE if the action was removed successfully; otherwise
returns FALSE.
<p> <p>See also <a href="#addTo">addTo</a>().

<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>
</h3><p>Sets the action's accelerator key to <em>key</em>.
See the <a href="qaction.html#accel-prop">"accel"</a> property for details.
<h3 class=fn>void <a name="setDisabled"></a>QAction::setDisabled ( bool&nbsp;disable )<tt> [slot]</tt>
</h3>
Disables the action if <em>disable</em> is TRUE; otherwise
enables the action.
<p> See the <a href="#enabled-prop">enabled</a> documentation for more information.

<h3 class=fn>void <a name="setEnabled"></a>QAction::setEnabled ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether the action is enabled.
See the <a href="qaction.html#enabled-prop">"enabled"</a> property for details.
<h3 class=fn>void <a name="setIconSet"></a>QAction::setIconSet ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the action's icon.
See the <a href="qaction.html#iconSet-prop">"iconSet"</a> property for details.
<h3 class=fn>void <a name="setMenuText"></a>QAction::setMenuText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the action's menu text.
See the <a href="qaction.html#menuText-prop">"menuText"</a> property for details.
<h3 class=fn>void <a name="setOn"></a>QAction::setOn ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether a toggle action is on.
See the <a href="qaction.html#on-prop">"on"</a> property for details.
<h3 class=fn>void <a name="setStatusTip"></a>QAction::setStatusTip ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the action's status tip.
See the <a href="qaction.html#statusTip-prop">"statusTip"</a> property for details.
<h3 class=fn>void <a name="setText"></a>QAction::setText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the action's descriptive text.
See the <a href="qaction.html#text-prop">"text"</a> property for details.
<h3 class=fn>void <a name="setToggleAction"></a>QAction::setToggleAction ( bool )<tt> [virtual]</tt>
</h3><p>Sets whether the action is a toggle action.
See the <a href="qaction.html#toggleAction-prop">"toggleAction"</a> property for details.
<h3 class=fn>void <a name="setToolTip"></a>QAction::setToolTip ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the action's tool tip.
See the <a href="qaction.html#toolTip-prop">"toolTip"</a> property for details.
<h3 class=fn>void <a name="setVisible"></a>QAction::setVisible ( bool )<tt> [slot]</tt>
</h3><p>Sets whether the action can be seen (e.g. in menus and toolbars).
See the <a href="qaction.html#visible-prop">"visible"</a> property for details.
<h3 class=fn>void <a name="setWhatsThis"></a>QAction::setWhatsThis ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [virtual]</tt>
</h3><p>Sets the action's "What's This?" help text.
See the <a href="qaction.html#whatsThis-prop">"whatsThis"</a> property for details.
<h3 class=fn><a href="qstring.html">QString</a> <a name="statusTip"></a>QAction::statusTip () const
</h3><p>Returns the action's status tip.
See the <a href="qaction.html#statusTip-prop">"statusTip"</a> property for details.
<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QAction::text () const
</h3><p>Returns the action's descriptive text.
See the <a href="qaction.html#text-prop">"text"</a> property for details.
<h3 class=fn>void <a name="toggle"></a>QAction::toggle ()<tt> [slot]</tt>
</h3>
Toggles the state of a toggle action.
<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>.

<h3 class=fn>void <a name="toggled"></a>QAction::toggled ( bool&nbsp;on )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when a toggle action changes state; command
actions and <a href="qactiongroup.html">QActionGroup</a>s don't emit <a href="#toggled">toggled</a>().
<p> The <em>on</em> argument denotes the new state: If <em>on</em> is TRUE the
toggle action is switched on, and if <em>on</em> is FALSE the toggle
action is switched off.
<p> To trigger a user command depending on whether a toggle action has
been switched on or off connect it to a slot that takes a bool to
indicate the state, e.g.
<p> 

<pre>        <a href="qmainwindow.html">QMainWindow</a> * window = new <a href="qmainwindow.html">QMainWindow</a>;
</pre><pre>        QAction * labelonoffaction = new QAction( window, "labelonoff" );
</pre><pre>    <a name="x2108"></a>    QObject::<a href="qobject.html#connect">connect</a>( labelonoffaction, SIGNAL( <a href="#toggled">toggled</a>( bool ) ),
    <a name="x2109"></a>                      window, SLOT( <a href="qmainwindow.html#setUsesTextLabel">setUsesTextLabel</a>( bool ) ) );
</pre>
<p> <p>See also <a href="#activated">activated</a>(), <a href="#toggleAction-prop">toggleAction</a>, and <a href="#on-prop">on</a>.

<p>Example: <a href="qaction.html#x2108">action/toggleaction/toggleaction.cpp</a>.
<h3 class=fn><a href="qstring.html">QString</a> <a name="toolTip"></a>QAction::toolTip () const
</h3><p>Returns the action's tool tip.
See the <a href="qaction.html#toolTip-prop">"toolTip"</a> property for details.
<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QAction::whatsThis () const
</h3><p>Returns the action's "What's This?" help text.
See the <a href="qaction.html#whatsThis-prop">"whatsThis"</a> property for details.
<hr><h2>Property Documentation</h2>
<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel-prop"></a>accel</h3>
<p>This property holds the action's accelerator key.
<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
is no default accelerator key.

<p>Set this property's value with <a href="#setAccel">setAccel</a>() and get this property's value with <a href="#accel">accel</a>().
<h3 class=fn>bool <a name="enabled-prop"></a>enabled</h3>
<p>This property holds whether the action is enabled.
<p>Disabled actions can't be chosen by the user. They don't disappear
from the menu/tool bar but are displayed in a way which indicates
that they are unavailable, e.g. they might be displayed grayed
out.
<p> What's this? help on disabled actions is still available provided
the <a href="#whatsThis-prop">QAction::whatsThis</a> property is set.

<p>Set this property's value with <a href="#setEnabled">setEnabled</a>() and get this property's value with <a href="#isEnabled">isEnabled</a>().
<h3 class=fn><a href="qiconset.html">QIconSet</a> <a name="iconSet-prop"></a>iconSet</h3>
<p>This property holds the action's icon.
<p>The icon is used as the tool button icon and in the menu to the
left of the menu text. There is no default icon.
<p> If a null icon (<a href="qiconset.html#isNull">QIconSet::isNull</a>() is passed into this function,
the icon of the action is cleared.
<p> (See the action/toggleaction/toggleaction.cpp example.)
<p> 
<p>Set this property's value with <a href="#setIconSet">setIconSet</a>() and get this property's value with <a href="#iconSet">iconSet</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="menuText-prop"></a>menuText</h3>
<p>This property holds the action's menu text.
<p>If the action is added to a menu the menu option will consist of
the icon (if there is one), the menu text and the accelerator (if
there is one). If the menu text is not explicitly set in the
constructor or by using <a href="#setMenuText">setMenuText</a>() the action's description
text will be used as the menu text. There is no default menu text.
<p> <p>See also <a href="#text-prop">text</a>.

<p>Set this property's value with <a href="#setMenuText">setMenuText</a>() and get this property's value with <a href="#menuText">menuText</a>().
<h3 class=fn>bool <a name="on-prop"></a>on</h3>
<p>This property holds whether a toggle action is on.
<p>This property is always on (TRUE) for command actions and
<a href="qactiongroup.html">QActionGroup</a>s; <a href="#setOn">setOn</a>() has no effect on them. For action's
where <a href="#isToggleAction">isToggleAction</a>() is TRUE, this property's default value is
off (FALSE).
<p> <p>See also <a href="#toggleAction-prop">toggleAction</a>.

<p>Set this property's value with <a href="#setOn">setOn</a>() and get this property's value with <a href="#isOn">isOn</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="statusTip-prop"></a>statusTip</h3>
<p>This property holds the action's status tip.
<p>The statusTip is displayed on all status bars that this action's
toplevel parent widget provides.
<p> If no status tip is defined, the action uses the tool tip text.
<p> There is no default statusTip text.
<p> <p>See also <a href="#statusTip-prop">statusTip</a> and <a href="#toolTip-prop">toolTip</a>.

<p>Set this property's value with <a href="#setStatusTip">setStatusTip</a>() and get this property's value with <a href="#statusTip">statusTip</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
<p>This property holds the action's descriptive text.
<p>If <a href="qmainwindow.html#usesTextLabel-prop">QMainWindow::usesTextLabel</a> is TRUE, the text appears as a
label in the relevant tool button. It also serves as the default
text in menus and tool tips if these have not been specifically
defined. There is no default text.
<p> <p>See also <a href="#menuText-prop">menuText</a>, <a href="#toolTip-prop">toolTip</a>, and <a href="#statusTip-prop">statusTip</a>.

<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
<h3 class=fn>bool <a name="toggleAction-prop"></a>toggleAction</h3>
<p>This property holds whether the action is a toggle action.
<p>A toggle action is one which has an on/off state. For example a
Bold toolbar button is either on or off. An action which is not a
toggle action is a command action; a command action is simply
executed, e.g. file save. This property's default is FALSE.
<p> In some situations, the state of one toggle action should depend
on the state of others. For example, "Left Align", "Center" and
"Right Align" toggle actions are mutually exclusive. To achieve
exclusive toggling, add the relevant toggle actions to a
<a href="qactiongroup.html">QActionGroup</a> with the <a href="qactiongroup.html#exclusive-prop">QActionGroup::exclusive</a> property set to
TRUE.

<p>Set this property's value with <a href="#setToggleAction">setToggleAction</a>() and get this property's value with <a href="#isToggleAction">isToggleAction</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="toolTip-prop"></a>toolTip</h3>
<p>This property holds the action's tool tip.
<p>This text is used for the tool tip. If no status tip has been set
the tool tip will be used for the status tip.
<p> If no tool tip is specified the action's text is used, and if that
hasn't been specified the description text is used as the tool tip
text.
<p> There is no default tool tip text.
<p> <p>See also <a href="#statusTip-prop">statusTip</a> and <a href="#accel-prop">accel</a>.

<p>Set this property's value with <a href="#setToolTip">setToolTip</a>() and get this property's value with <a href="#toolTip">toolTip</a>().
<h3 class=fn>bool <a name="visible-prop"></a>visible</h3>
<p>This property holds whether the action can be seen (e.g. in menus and toolbars).
<p>If <em>visible</em> is TRUE the action can be seen (e.g. in menus and
toolbars) and chosen by the user; if <em>visible</em> is FALSE the
action cannot be seen or chosen by the user.
<p> Actions which are not visible are <em>not</em> grayed out; they do not
appear at all.

<p>Set this property's value with <a href="#setVisible">setVisible</a>() and get this property's value with <a href="#isVisible">isVisible</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis-prop"></a>whatsThis</h3>
<p>This property holds the action's "What's This?" help text.
<p>The whats this text is used to provide a brief description of the
action. The text may contain rich text (HTML-like tags -- see
<a href="qstylesheet.html">QStyleSheet</a> for the list of supported tags). There is no default
"What's This" text.
<p> <p>See also <a href="qwhatsthis.html">QWhatsThis</a>.

<p>Set this property's value with <a href="#setWhatsThis">setWhatsThis</a>() and get this property's value with <a href="#whatsThis">whatsThis</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>