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"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { 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 Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main 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 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
|
---|
35 | action that can appear both in menus and tool bars.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qaction-h.html">qaction.h</a>></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 * parent, const char * name = 0 )</li>
|
---|
44 | <li class=fn><a href="#QAction-2"><b>QAction</b></a> ( const QString & menuText, QKeySequence accel, QObject * parent, const char * name = 0 )</li>
|
---|
45 | <li class=fn><a href="#QAction-3"><b>QAction</b></a> ( const QIconSet & icon, const QString & menuText, QKeySequence accel, QObject * parent, const char * name = 0 )</li>
|
---|
46 | <li class=fn>QAction ( const QString & text, const QIconSet & icon, const QString & menuText, QKeySequence accel, QObject * parent, const char * name = 0, bool toggle = FALSE ) <em>(obsolete)</em></li>
|
---|
47 | <li class=fn>QAction ( const QString & text, const QString & menuText, QKeySequence accel, QObject * parent, const char * name = 0, bool toggle = FALSE ) <em>(obsolete)</em></li>
|
---|
48 | <li class=fn>QAction ( QObject * parent, const char * name, bool toggle ) <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 & )</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 & )</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 & )</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 & )</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 & )</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 & )</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 QKeySequence & 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 * w )</li>
|
---|
70 | <li class=fn>virtual bool <a href="#removeFrom"><b>removeFrom</b></a> ( QWidget * 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 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 on )</li>
|
---|
85 | </ul>
|
---|
86 | <h2>Properties</h2>
|
---|
87 | <ul>
|
---|
88 | <li class=fn>QKeySequence <a href="#accel-prop"><b>accel</b></a> - the action's accelerator key</li>
|
---|
89 | <li class=fn>bool <a href="#enabled-prop"><b>enabled</b></a> - whether the action is enabled</li>
|
---|
90 | <li class=fn>QIconSet <a href="#iconSet-prop"><b>iconSet</b></a> - the action's icon</li>
|
---|
91 | <li class=fn>QString <a href="#menuText-prop"><b>menuText</b></a> - the action's menu text</li>
|
---|
92 | <li class=fn>bool <a href="#on-prop"><b>on</b></a> - whether a toggle action is on</li>
|
---|
93 | <li class=fn>QString <a href="#statusTip-prop"><b>statusTip</b></a> - the action's status tip</li>
|
---|
94 | <li class=fn>QString <a href="#text-prop"><b>text</b></a> - the action's descriptive text</li>
|
---|
95 | <li class=fn>bool <a href="#toggleAction-prop"><b>toggleAction</b></a> - whether the action is a toggle action</li>
|
---|
96 | <li class=fn>QString <a href="#toolTip-prop"><b>toolTip</b></a> - the action's tool tip</li>
|
---|
97 | <li class=fn>bool <a href="#visible-prop"><b>visible</b></a> - 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> - 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 * actionWidget, QWidget * container )</li>
|
---|
103 | <li class=fn>virtual void <a href="#addedTo-2"><b>addedTo</b></a> ( int index, QPopupMenu * menu )</li>
|
---|
104 | </ul>
|
---|
105 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
106 |
|
---|
107 |
|
---|
108 | The QAction class provides an abstract user interface
|
---|
109 | action 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
|
---|
114 | option, a toolbar button and a keyboard accelerator. Since the
|
---|
115 | same action must be performed regardless of how the action was
|
---|
116 | invoked, and since the menu and toolbar should be kept in sync, it
|
---|
117 | is useful to represent a command as an <em>action</em>. An action can be
|
---|
118 | added to a menu and a toolbar and will automatically keep them in
|
---|
119 | sync. For example, if the user presses a Bold toolbar button the
|
---|
120 | Bold menu item will automatically be checked.
|
---|
121 | <p> A QAction may contain an icon, a menu text, an accelerator, a
|
---|
122 | status text, a whats this text and a tool tip. Most of these can
|
---|
123 | be 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
|
---|
127 | command action, e.g. 'Open File' to invoke an open file dialog.
|
---|
128 | Toggle actions emit the <a href="#toggled">toggled</a>() signal when their state changes.
|
---|
129 | Both command and toggle actions emit the <a href="#activated">activated</a>() signal when
|
---|
130 | they are invoked. Use <a href="#setToggleAction">setToggleAction</a>() to set an action's toggled
|
---|
131 | status. 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
|
---|
133 | TRUE, or "off", isOn() returns FALSE.
|
---|
134 | <p> Actions are added to widgets (menus or toolbars) using <a href="#addTo">addTo</a>(),
|
---|
135 | and removed using <a href="#removeFrom">removeFrom</a>().
|
---|
136 | <p> Once a QAction has been created it should be added to the relevant
|
---|
137 | menu and toolbar and then connected to the slot which will perform
|
---|
138 | the action. For example:
|
---|
139 | <p>
|
---|
140 |
|
---|
141 | <pre> fileOpenAction = new QAction( QPixmap( fileopen ), "&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
|
---|
147 | fileSaveAction's <a href="#activated">activated</a>() signal to our own save() slot. Note
|
---|
148 | that at this point there is no menu or toolbar action, we'll add
|
---|
149 | them 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-><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>()->insertItem( "&File", file );
|
---|
154 | </pre><pre> fileSaveAction-><a href="#addTo">addTo</a>( file );
|
---|
155 | </pre>
|
---|
156 | <p> We create a toolbar and add our fileSaveAction to it. Similarly we
|
---|
157 | create a menu, add a top-level menu item, and add our
|
---|
158 | fileSaveAction.
|
---|
159 | <p> We recommend that actions are created as children of the window
|
---|
160 | that they are used in. In most cases actions will be children of
|
---|
161 | the application's main window.
|
---|
162 | <p> To prevent recursion, don't create an action as a child of a
|
---|
163 | widget 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> * parent, const char * name = 0 )
|
---|
168 | </h3>
|
---|
169 | Constructs 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
|
---|
173 | a 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
|
---|
175 | of a widget that the action is later added to.
|
---|
176 |
|
---|
177 | <h3 class=fn><a name="QAction-2"></a>QAction::QAction ( const <a href="qstring.html">QString</a> & menuText, <a href="qkeysequence.html">QKeySequence</a> accel, <a href="qobject.html">QObject</a> * parent, const char * name = 0 )
|
---|
178 | </h3>
|
---|
179 | This constructor results in an icon-less action with the the menu
|
---|
180 | text <em>menuText</em> and keyboard accelerator <em>accel</em>. It is a child
|
---|
181 | of <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
|
---|
183 | a member of it.
|
---|
184 | <p> For accelerators and status tips to work, <em>parent</em> must either be
|
---|
185 | a widget, or an action group whose parent is a widget.
|
---|
186 | <p> The action uses a stripped version of <em>menuText</em> (e.g. "&Menu
|
---|
187 | Option..." becomes "Menu Option") as descriptive text for
|
---|
188 | toolbuttons. You can override this by setting a specific
|
---|
189 | description with <a href="#setText">setText</a>(). The same text and <em>accel</em> will be
|
---|
190 | used for tool tips and status tips unless you provide text for
|
---|
191 | these 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
|
---|
194 | of a widget that the action is later added to.
|
---|
195 |
|
---|
196 | <h3 class=fn><a name="QAction-3"></a>QAction::QAction ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & menuText, <a href="qkeysequence.html">QKeySequence</a> accel, <a href="qobject.html">QObject</a> * parent, const char * name = 0 )
|
---|
197 | </h3>
|
---|
198 | This constructor creates an action with the following properties:
|
---|
199 | the icon or iconset <em>icon</em>, the menu text <em>menuText</em> and
|
---|
200 | keyboard accelerator <em>accel</em>. It is a child of <em>parent</em> and
|
---|
201 | called <em>name</em>.
|
---|
202 | <p> If <em>parent</em> is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes
|
---|
203 | a member of it.
|
---|
204 | <p> For accelerators and status tips to work, <em>parent</em> must either be
|
---|
205 | a widget, or an action group whose parent is a widget.
|
---|
206 | <p> The action uses a stripped version of <em>menuText</em> (e.g. "&Menu
|
---|
207 | Option..." becomes "Menu Option") as descriptive text for
|
---|
208 | toolbuttons. You can override this by setting a specific
|
---|
209 | description with <a href="#setText">setText</a>(). The same text and <em>accel</em> will be
|
---|
210 | used for tool tips and status tips unless you provide text for
|
---|
211 | these 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
|
---|
214 | of a widget that the action is later added to.
|
---|
215 |
|
---|
216 | <h3 class=fn><a name="QAction-4"></a>QAction::QAction ( const <a href="qstring.html">QString</a> & text, const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & menuText, <a href="qkeysequence.html">QKeySequence</a> accel, <a href="qobject.html">QObject</a> * parent, const char * name = 0, bool 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:
|
---|
219 | the description <em>text</em>, the icon or iconset <em>icon</em>, the menu
|
---|
220 | text <em>menuText</em> and keyboard accelerator <em>accel</em>. It is a child
|
---|
221 | of <em>parent</em> and called <em>name</em>. If <em>toggle</em> is TRUE the action
|
---|
222 | will 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
|
---|
224 | a member of it.
|
---|
225 | <p> For accelerators and status tips to work, <em>parent</em> must either be
|
---|
226 | a 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
|
---|
228 | tips unless you provide specific text for these using <a href="#setToolTip">setToolTip</a>()
|
---|
229 | and <a href="#setStatusTip">setStatusTip</a>().
|
---|
230 |
|
---|
231 | <h3 class=fn><a name="QAction-5"></a>QAction::QAction ( const <a href="qstring.html">QString</a> & text, const <a href="qstring.html">QString</a> & menuText, <a href="qkeysequence.html">QKeySequence</a> accel, <a href="qobject.html">QObject</a> * parent, const char * name = 0, bool 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
|
---|
234 | description <em>text</em>, the menu text <em>menuText</em> and the keyboard
|
---|
235 | 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,
|
---|
236 | otherwise 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
|
---|
239 | a 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
|
---|
241 | tips unless you provide specific text for these using <a href="#setToolTip">setToolTip</a>()
|
---|
242 | and <a href="#setStatusTip">setStatusTip</a>().
|
---|
243 |
|
---|
244 | <h3 class=fn><a name="QAction-6"></a>QAction::QAction ( <a href="qobject.html">QObject</a> * parent, const char * name, bool 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
|
---|
248 | it 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
|
---|
252 | a widget, or an action group whose parent is a widget.
|
---|
253 |
|
---|
254 | <h3 class=fn><a name="~QAction"></a>QAction::~QAction ()
|
---|
255 | </h3>
|
---|
256 | Destroys 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.
|
---|
260 | See 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>
|
---|
263 | Activates the action and executes all connected slots.
|
---|
264 | This 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,
|
---|
271 | e.g. when the user clicks a menu option or a toolbar button or
|
---|
272 | presses 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> * w )<tt> [virtual]</tt>
|
---|
278 | </h3>
|
---|
279 | Adds 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
|
---|
282 | button; 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
|
---|
284 | FALSE otherwise. (If <em>w</em> is not a QToolBar or QPopupMenu the
|
---|
285 | action 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> * actionWidget, <a href="qwidget.html">QWidget</a> * container )<tt> [virtual protected]</tt>
|
---|
291 | </h3>
|
---|
292 | This function is called from the <a href="#addTo">addTo</a>() function when it has
|
---|
293 | created 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 index, <a href="qpopupmenu.html">QPopupMenu</a> * menu )<tt> [virtual protected]</tt>
|
---|
296 | </h3>
|
---|
297 | This 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
|
---|
299 | created a menu item at the index position <em>index</em> in the popup
|
---|
300 | menu <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.
|
---|
304 | See 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.
|
---|
307 | See 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.
|
---|
310 | See 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.
|
---|
313 | See 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.
|
---|
316 | See 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.
|
---|
319 | See 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> * w )<tt> [virtual]</tt>
|
---|
321 | </h3>
|
---|
322 | Removes the action from widget <em>w</em>.
|
---|
323 | <p> Returns TRUE if the action was removed successfully; otherwise
|
---|
324 | returns FALSE.
|
---|
325 | <p> <p>See also <a href="#addTo">addTo</a>().
|
---|
326 |
|
---|
327 | <h3 class=fn>void <a name="setAccel"></a>QAction::setAccel ( const <a href="qkeysequence.html">QKeySequence</a> & key )<tt> [virtual]</tt>
|
---|
328 | </h3><p>Sets the action's accelerator key to <em>key</em>.
|
---|
329 | See the <a href="qaction.html#accel-prop">"accel"</a> property for details.
|
---|
330 | <h3 class=fn>void <a name="setDisabled"></a>QAction::setDisabled ( bool disable )<tt> [slot]</tt>
|
---|
331 | </h3>
|
---|
332 | Disables the action if <em>disable</em> is TRUE; otherwise
|
---|
333 | enables 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.
|
---|
338 | See the <a href="qaction.html#enabled-prop">"enabled"</a> property for details.
|
---|
339 | <h3 class=fn>void <a name="setIconSet"></a>QAction::setIconSet ( const <a href="qiconset.html">QIconSet</a> & )<tt> [virtual]</tt>
|
---|
340 | </h3><p>Sets the action's icon.
|
---|
341 | See the <a href="qaction.html#iconSet-prop">"iconSet"</a> property for details.
|
---|
342 | <h3 class=fn>void <a name="setMenuText"></a>QAction::setMenuText ( const <a href="qstring.html">QString</a> & )<tt> [virtual]</tt>
|
---|
343 | </h3><p>Sets the action's menu text.
|
---|
344 | See 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.
|
---|
347 | See the <a href="qaction.html#on-prop">"on"</a> property for details.
|
---|
348 | <h3 class=fn>void <a name="setStatusTip"></a>QAction::setStatusTip ( const <a href="qstring.html">QString</a> & )<tt> [virtual]</tt>
|
---|
349 | </h3><p>Sets the action's status tip.
|
---|
350 | See the <a href="qaction.html#statusTip-prop">"statusTip"</a> property for details.
|
---|
351 | <h3 class=fn>void <a name="setText"></a>QAction::setText ( const <a href="qstring.html">QString</a> & )<tt> [virtual]</tt>
|
---|
352 | </h3><p>Sets the action's descriptive text.
|
---|
353 | See 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.
|
---|
356 | See the <a href="qaction.html#toggleAction-prop">"toggleAction"</a> property for details.
|
---|
357 | <h3 class=fn>void <a name="setToolTip"></a>QAction::setToolTip ( const <a href="qstring.html">QString</a> & )<tt> [virtual]</tt>
|
---|
358 | </h3><p>Sets the action's tool tip.
|
---|
359 | See 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).
|
---|
362 | See the <a href="qaction.html#visible-prop">"visible"</a> property for details.
|
---|
363 | <h3 class=fn>void <a name="setWhatsThis"></a>QAction::setWhatsThis ( const <a href="qstring.html">QString</a> & )<tt> [virtual]</tt>
|
---|
364 | </h3><p>Sets the action's "What's This?" help text.
|
---|
365 | See 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.
|
---|
368 | See 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.
|
---|
371 | See 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>
|
---|
374 | Toggles 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 on )<tt> [signal]</tt>
|
---|
378 | </h3>
|
---|
379 |
|
---|
380 | <p> This signal is emitted when a toggle action changes state; command
|
---|
381 | actions 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
|
---|
383 | toggle action is switched on, and if <em>on</em> is FALSE the toggle
|
---|
384 | action is switched off.
|
---|
385 | <p> To trigger a user command depending on whether a toggle action has
|
---|
386 | been switched on or off connect it to a slot that takes a bool to
|
---|
387 | indicate 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.
|
---|
400 | See 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.
|
---|
403 | See 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
|
---|
408 | is 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
|
---|
414 | from the menu/tool bar but are displayed in a way which indicates
|
---|
415 | that they are unavailable, e.g. they might be displayed grayed
|
---|
416 | out.
|
---|
417 | <p> What's this? help on disabled actions is still available provided
|
---|
418 | the <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
|
---|
424 | left 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,
|
---|
426 | the 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
|
---|
433 | the icon (if there is one), the menu text and the accelerator (if
|
---|
434 | there is one). If the menu text is not explicitly set in the
|
---|
435 | constructor or by using <a href="#setMenuText">setMenuText</a>() the action's description
|
---|
436 | text 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
|
---|
444 | where <a href="#isToggleAction">isToggleAction</a>() is TRUE, this property's default value is
|
---|
445 | off (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
|
---|
452 | toplevel 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
|
---|
461 | label in the relevant tool button. It also serves as the default
|
---|
462 | text in menus and tool tips if these have not been specifically
|
---|
463 | defined. 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
|
---|
470 | Bold toolbar button is either on or off. An action which is not a
|
---|
471 | toggle action is a command action; a command action is simply
|
---|
472 | executed, e.g. file save. This property's default is FALSE.
|
---|
473 | <p> In some situations, the state of one toggle action should depend
|
---|
474 | on the state of others. For example, "Left Align", "Center" and
|
---|
475 | "Right Align" toggle actions are mutually exclusive. To achieve
|
---|
476 | exclusive 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
|
---|
478 | TRUE.
|
---|
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
|
---|
484 | the 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
|
---|
486 | hasn't been specified the description text is used as the tool tip
|
---|
487 | text.
|
---|
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
|
---|
495 | toolbars) and chosen by the user; if <em>visible</em> is FALSE the
|
---|
496 | action cannot be seen or chosen by the user.
|
---|
497 | <p> Actions which are not visible are <em>not</em> grayed out; they do not
|
---|
498 | appear 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
|
---|
504 | action. 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>
|
---|
512 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
513 | Copyright © 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 © 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>
|
---|