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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QAction Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QAction Class Reference</h1><br clear="all">
<p>
The QAction class abstracts a user interface action that can appear both in menus and tool bars.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qaction-h.html">qaction.h</a>></code>
<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><div class="fn"><a href="#38801f"><b>QAction</b></a>(QObject*parent=0, constchar*name=0, booltoggle=FALSE)</div>
<li><div class="fn"><a href="#58b1b9"><b>QAction</b></a>(constQString&text, constQIconSet&icon, constQString&menuText, intaccel, QObject*parent, constchar*name=0, booltoggle=FALSE)</div>
<li><div class="fn"><a href="#e21ea0"><b>QAction</b></a>(constQString&text, constQString&menuText, intaccel, QObject*parent, constchar*name=0, booltoggle=FALSE)</div>
<li><div class="fn"><a href="#781c4a"><b>~QAction</b></a>()</div>
<li><div class="fn">virtualvoid<a href="#cbb66c"><b>setIconSet</b></a>(constQIconSet&)</div>
<li><div class="fn">QIconSet<a href="#015c9d"><b>iconSet</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#8fb958"><b>setText</b></a>(constQString&)</div>
<li><div class="fn">QString<a href="#9c0ef3"><b>text</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#480ba7"><b>setMenuText</b></a>(constQString&)</div>
<li><div class="fn">QString<a href="#542aa7"><b>menuText</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#7f2473"><b>setToolTip</b></a>(constQString&)</div>
<li><div class="fn">QString<a href="#fa700b"><b>toolTip</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#cee49c"><b>setStatusTip</b></a>(constQString&)</div>
<li><div class="fn">QString<a href="#c38884"><b>statusTip</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#0dca55"><b>setWhatsThis</b></a>(constQString&)</div>
<li><div class="fn">QString<a href="#9e05fc"><b>whatsThis</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#0e2b7e"><b>setAccel</b></a>(intkey)</div>
<li><div class="fn">int<a href="#4ba101"><b>accel</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#6a8b9c"><b>setToggleAction</b></a>(bool)</div>
<li><div class="fn">bool<a href="#a21f49"><b>isToggleAction</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#657bbf"><b>setOn</b></a>(bool)</div>
<li><div class="fn">bool<a href="#958807"><b>isOn</b></a>()const</div>
<li><div class="fn">bool<a href="#1a354c"><b>isEnabled</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#780f84"><b>addTo</b></a>(QWidget*)</div>
<li><div class="fn">virtualbool<a href="#80c814"><b>removeFrom</b></a>(QWidget*)</div>
</ul>
<h2>Public Slots</h2>
<ul>
<li><div class="fn">virtualvoid<a href="#a536b2"><b>setEnabled</b></a>(bool)</div>
</ul>
<h2>Signals</h2>
<ul>
<li><div class="fn">void<a href="#676dd4"><b>activated</b></a>()</div>
<li><div class="fn">void<a href="#bb3ce9"><b>toggled</b></a>(bool)</div>
</ul>
<h2>Properties</h2>
<table border=1 cellpadding=3 cellspacing=0>
<tr><th>Type<th>Name<th>READ<th>WRITE<th>Options
<tr><td>bool<td>toggleAction<td>isToggleAction<td>setToggleAction<td>
<tr><td>bool<td>on<td>isOn<td>setOn<td>
<tr><td>bool<td>enabled<td>isEnabled<td>setEnabled<td>
<tr><td>QIconSet<td>iconSet<td>iconSet<td>setIconSet<td>
<tr><td>QString<td>text<td>text<td>setText<td>
<tr><td>QString<td>menuText<td>menuText<td>setMenuText<td>
<tr><td>QString<td>toolTip<td>toolTip<td>setToolTip<td>
<tr><td>QString<td>statusTip<td>statusTip<td>setStatusTip<td>
<tr><td>QString<td>whatsThis<td>whatsThis<td>setWhatsThis<td>
<tr><td>int<td>accel<td>accel<td>setAccel<td>
</table>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QAction class abstracts a user interface action that can appear both in menus and tool bars.
<p>
There are two basic kind of user interface actions, command actions
and options. QAction usually models a command action, for example
"open file". When the actual action shall be performed, it emits the
<a href="#676dd4">activated</a>() signal. Options, for example the drawing tools in a
paint program, are represented by toggle actions (see
<a href="#6a8b9c">setToggleAction</a>() ). A toggle action emits a <a href="#bb3ce9">toggled</a>() signal
whenever it changes state. Several toggle actions can be combined in
a <a href="qactiongroup.html">QActionGroup</a>.
<p>To provide an action to the user, use <a href="#780f84">addTo</a>() to add it to either a
menu or a tool bar, for example:
<pre> <a href="qpopupmenu.html">QPopupMenu</a>* popup = new <a href="qpopupmenu.html">QPopupMenu</a>;
<a href="qaction.html">QAction</a>* myAction= new <a href="qaction.html">QAction</a>;
myAction-><a href="#8fb958">setText</a>( "MyAction" );
myAction-><a href="#780f84">addTo</a>( popup );
</pre>
<p>You can add an action to an arbitrary number of menus and toolbars
and remove it again with <a href="#80c814">removeFrom</a>().
<p>Changing an action's properties, for example using <a href="#a536b2">setEnabled</a>(),
<a href="#657bbf">setOn</a>() or <a href="#8fb958">setText</a>(), immediately shows up in all
representations. Other properties that define the way an action is
presented to the user are <a href="#015c9d">iconSet</a>(), <a href="#542aa7">menuText</a>(), <a href="#fa700b">toolTip</a>(),
<a href="#c38884">statusTip</a>() and <a href="#9e05fc">whatsThis</a>().
<p>An action may also be triggered by an accelerator key declared with
<a href="#0e2b7e">setAccel</a>(). Since accelerators are window specific, the application
window has to be an ancestor of the action. Generally, it is
therefore a good idea to always create actions as direct children of
the main window.
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="38801f"></a>QAction::QAction(<a href="qobject.html">QObject</a>*parent=0, constchar*name=0, booltoggle=FALSE)</h3>
<p>Constructs an action with parent <em>parent</em> and name <em>name.</em>
<p>If <em>toggle</em> is TRUE, the action becomes a toggle action.
<p>If the parent is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes a
member of it.
<p>Note: for accelerators to work, the parent or one of its ancestors
has to be the application window.
<h3 class="fn"><a name="58b1b9"></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, intaccel, <a href="qobject.html">QObject</a>*parent, constchar*name=0, booltoggle=FALSE)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<p>Constructs an action with text <em>text,</em> icon <em>icon,</em> menu text
<em>menuText,</em> a keyboard accelerator <em>accel,</em> a <em>parent</em> and name
<em>name. text</em> will also show up in tooltips, unless you call
<a href="#7f2473">setToolTip</a>() with a different tip later.
<p>If the parent is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes a
member of it.
<p>Note: for accelerators to work, the parent or one of its ancestors
has to be the application window.
<h3 class="fn"><a name="e21ea0"></a>QAction::QAction(const<a href="qstring.html">QString</a>&text, const<a href="qstring.html">QString</a>&menuText, intaccel, <a href="qobject.html">QObject</a>*parent, constchar*name=0, booltoggle=FALSE)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<p>Constructs an action with text <em>text,</em> menu text <em>menuText,</em> a keyboard accelerator <em>accel,</em> a <em>parent</em> and name <em>name. text</em> will also show up in tooltips, unless you call
<a href="#7f2473">setToolTip</a>() with a different tip later.
<p>If <em>toggle</em> is TRUE, the action becomes a toggle action.
<p>If the parent is a <a href="qactiongroup.html">QActionGroup</a>, the action automatically becomes a
member of it.
<p>Note: for accelerators to work, the parent or one of its ancestors
has to be the application window.
<h3 class="fn"><a name="781c4a"></a>QAction::~QAction()</h3>
<p>Destroys the object and frees any allocated resources.
<h3 class="fn">int<a name="4ba101"></a>QAction::accel()const</h3>
<p>Returns the acceleration key.
<p>See also <a href="#0e2b7e">setAccel</a>().
<h3 class="fn">void<a name="676dd4"></a>QAction::activated() <code>[signal]</code></h3>
<p>This signal is emitted when the action was activated by the user.
<p>See also <a href="#bb3ce9">toggled</a>().
<h3 class="fn">bool<a name="780f84"></a>QAction::addTo(<a href="qwidget.html">QWidget</a>*w) <code>[virtual]</code></h3>
<p>Adds this action to widget <em>w.</em>
<p>Currently supported widget types are <a href="qtoolbar.html">QToolBar</a> and <a href="qpopupmenu.html">QPopupMenu</a>.
<p>Returns TRUE when the action was added successfully, FALSE
otherwise.
<p>See also <a href="#80c814">removeFrom</a>().
<p>Reimplemented in <a href="qactiongroup.html#113ed9">QActionGroup</a>.
<h3 class="fn"><a href="qiconset.html">QIconSet</a><a name="015c9d"></a>QAction::iconSet()const</h3>
<p>Returns the icon set.
<p>See also <a href="#cbb66c">setIconSet</a>();.
<h3 class="fn">bool<a name="1a354c"></a>QAction::isEnabled()const</h3>
<p>Returns TRUE if the action is enabled, or FALSE if it is disabled.
<p>See also <a href="#a536b2">setEnabled</a>().
<h3 class="fn">bool<a name="958807"></a>QAction::isOn()const</h3>
<p>Returns TRUE if this toggle action is switched on, or FALSE if it is
switched off.
<p>See also <a href="#657bbf">setOn</a>() and <a href="#a21f49">isToggleAction</a>().
<h3 class="fn">bool<a name="a21f49"></a>QAction::isToggleAction()const</h3>
<p>Returns whether the action is a toggle action or not.
<p>See also <a href="#6a8b9c">setToggleAction</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="542aa7"></a>QAction::menuText()const</h3>
<p>Returns the text used for menu items.
<p>If no menu text has been defined yet, this is the same as <a href="#9c0ef3">text</a>().
<p>See also <a href="#480ba7">setMenuText</a>() and <a href="#9c0ef3">text</a>().
<h3 class="fn">bool<a name="80c814"></a>QAction::removeFrom(<a href="qwidget.html">QWidget</a>*w) <code>[virtual]</code></h3>
<p>Removes the action from widget <em>w</em>
<p>Returns TRUE when the action was removed successfully, FALSE
otherwise.
<p>See also <a href="#780f84">addTo</a>().
<p>Reimplemented in <a href="qactiongroup.html#01e8fd">QActionGroup</a>.
<h3 class="fn">void<a name="0e2b7e"></a>QAction::setAccel(intkey) <code>[virtual]</code></h3>
<p>Sets the action's accelerator to <em>key.</em>
<p>Note: For accelerators to work, the parent or one of its ancestors
has to be the application window.
<p>See also <a href="#4ba101">accel</a>().
<h3 class="fn">void<a name="a536b2"></a>QAction::setEnabled(boolenable) <code>[virtualslot]</code></h3>
<p>Enables the action if <em>enable</em> is TRUE, otherwise disables it.
<p>Menu items and/or tool buttons presenting the action to the user are
updated accordingly.
<p>See also <a href="#1a354c">isEnabled</a>().
<p>Reimplemented in <a href="qactiongroup.html#24497a">QActionGroup</a>.
<h3 class="fn">void<a name="cbb66c"></a>QAction::setIconSet(const<a href="qiconset.html">QIconSet</a>&icon) <code>[virtual]</code></h3>
<p>Sets the icon set to <em>icon.</em>
<p>See also <a href="#015c9d">iconSet</a>();.
<h3 class="fn">void<a name="480ba7"></a>QAction::setMenuText(const<a href="qstring.html">QString</a>&text) <code>[virtual]</code></h3>
<p>Sets a special text <em>text</em> for menu items. Use this to specify
ellipses or keyboard shortcuts that should not show up in tooltips or
as button text.
<p>See also <a href="#8fb958">setText</a>() and <a href="#542aa7">menuText</a>().
<h3 class="fn">void<a name="657bbf"></a>QAction::setOn(boolenable) <code>[virtual]</code></h3>
<p>Switches a toggle action on if <em>enable</em> is TRUE or off if <em>enable</em> is
FALSE.
<p>This function should be called only for toggle actions.
<p>See also <a href="#958807">isOn</a>() and <a href="#6a8b9c">setToggleAction</a>().
<h3 class="fn">void<a name="cee49c"></a>QAction::setStatusTip(const<a href="qstring.html">QString</a>&tip) <code>[virtual]</code></h3>
<p>Sets the status tip to <em>tip.</em> The tip will be displayed on
all status bars the topmost parent of the action provides.
<p>See also <a href="#c38884">statusTip</a>().
<h3 class="fn">void<a name="8fb958"></a>QAction::setText(const<a href="qstring.html">QString</a>&text) <code>[virtual]</code></h3>
<p>Sets the text to <em>text.</em>
<p>See also <a href="#480ba7">setMenuText</a>() and <a href="#9c0ef3">text</a>().
<h3 class="fn">void<a name="6a8b9c"></a>QAction::setToggleAction(boolenable) <code>[virtual]</code></h3>
<p>Makes the action a toggle action if <em>enable</em> is TRUE, or a
normal action if <em>enable</em> is FALSE.
<p>You may want to add toggle actions to a <a href="qactiongroup.html">QActionGroup</a> for exclusive
toggling.
<p>See also <a href="#a21f49">isToggleAction</a>().
<h3 class="fn">void<a name="7f2473"></a>QAction::setToolTip(const<a href="qstring.html">QString</a>&tip) <code>[virtual]</code></h3>
<p>Sets the tool tip to <em>tip.</em>
<p>See also <a href="#fa700b">toolTip</a>().
<h3 class="fn">void<a name="0dca55"></a>QAction::setWhatsThis(const<a href="qstring.html">QString</a>&whatsThis) <code>[virtual]</code></h3>
<p>Sets What's This help to <em>whatsThis.</em>
<p>See also <a href="#9e05fc">whatsThis</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="c38884"></a>QAction::statusTip()const</h3>
<p>Returns the current status tip.
<p>If not status tip has been defined yet, this is the same as <a href="#fa700b">toolTip</a>()
<p>See also <a href="#cee49c">setStatusTip</a>() and <a href="#fa700b">toolTip</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="9c0ef3"></a>QAction::text()const</h3>
<p>Returns the current text.
<p>See also <a href="#8fb958">setText</a>() and <a href="#542aa7">menuText</a>().
<h3 class="fn">void<a name="bb3ce9"></a>QAction::toggled(bool) <code>[signal]</code></h3>
<p>This signal is emitted when a toggle action changes state.
<p>See also <a href="#676dd4">activated</a>() and <a href="#6a8b9c">setToggleAction</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="fa700b"></a>QAction::toolTip()const</h3>
<p>Returns the current tool tip.
<p>If no tool tip has been defined yet, it returns text
and a hotkey hint.
<p>See also <a href="#7f2473">setToolTip</a>() and <a href="#9c0ef3">text</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="9e05fc"></a>QAction::whatsThis()const</h3>
<p>Returns the What's This help for this action.
<p>See also <a href="#0dca55">setWhatsThis</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<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 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|