source: trunk/doc/html/qmenudata.html@ 190

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

reference documentation added

File size: 51.6 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmenudata.cpp:61 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QMenuData Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QMenuData Class Reference</h1>
33
34<p>The QMenuData class is a base class for QMenuBar and QPopupMenu.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qmenudata-h.html">qmenudata.h</a>&gt;</tt>
37<p>Inherited by <a href="qmenubar.html">QMenuBar</a> and <a href="qpopupmenu.html">QPopupMenu</a>.
38<p><a href="qmenudata-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QMenuData"><b>QMenuData</b></a> ()</li>
42<li class=fn>virtual <a href="#~QMenuData"><b>~QMenuData</b></a> ()</li>
43<li class=fn>uint <a href="#count"><b>count</b></a> () const</li>
44<li class=fn>int <a href="#insertItem"><b>insertItem</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;QKeySequence&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
45<li class=fn>int <a href="#insertItem-2"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;QKeySequence&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
46<li class=fn>int <a href="#insertItem-3"><b>insertItem</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;QKeySequence&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
47<li class=fn>int <a href="#insertItem-4"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;QKeySequence&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
48<li class=fn>int <a href="#insertItem-5"><b>insertItem</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
49<li class=fn>int <a href="#insertItem-6"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
50<li class=fn>int <a href="#insertItem-7"><b>insertItem</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, QPopupMenu&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
51<li class=fn>int <a href="#insertItem-8"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;text, QPopupMenu&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
52<li class=fn>int <a href="#insertItem-9"><b>insertItem</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
53<li class=fn>int <a href="#insertItem-a"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
54<li class=fn>int <a href="#insertItem-b"><b>insertItem</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, QPopupMenu&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
55<li class=fn>int <a href="#insertItem-c"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, QPopupMenu&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
56<li class=fn>int <a href="#insertItem-d"><b>insertItem</b></a> ( QWidget&nbsp;*&nbsp;widget, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
57<li class=fn>int <a href="#insertItem-e"><b>insertItem</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, QCustomMenuItem&nbsp;*&nbsp;custom, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
58<li class=fn>int <a href="#insertItem-f"><b>insertItem</b></a> ( QCustomMenuItem&nbsp;*&nbsp;custom, int&nbsp;id = -1, int&nbsp;index = -1 )</li>
59<li class=fn>int <a href="#insertSeparator"><b>insertSeparator</b></a> ( int&nbsp;index = -1 )</li>
60<li class=fn>void <a href="#removeItem"><b>removeItem</b></a> ( int&nbsp;id )</li>
61<li class=fn>void <a href="#removeItemAt"><b>removeItemAt</b></a> ( int&nbsp;index )</li>
62<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
63<li class=fn>QKeySequence <a href="#accel"><b>accel</b></a> ( int&nbsp;id ) const</li>
64<li class=fn>void <a href="#setAccel"><b>setAccel</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;key, int&nbsp;id )</li>
65<li class=fn>QIconSet * <a href="#iconSet"><b>iconSet</b></a> ( int&nbsp;id ) const</li>
66<li class=fn>QString <a href="#text"><b>text</b></a> ( int&nbsp;id ) const</li>
67<li class=fn>QPixmap * <a href="#pixmap"><b>pixmap</b></a> ( int&nbsp;id ) const</li>
68<li class=fn>void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( int&nbsp;id, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
69<li class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> ( int&nbsp;id ) const</li>
70<li class=fn>void <a href="#changeItem"><b>changeItem</b></a> ( int&nbsp;id, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
71<li class=fn>void <a href="#changeItem-2"><b>changeItem</b></a> ( int&nbsp;id, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
72<li class=fn>void <a href="#changeItem-3"><b>changeItem</b></a> ( int&nbsp;id, const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
73<li class=fn>void <a href="#changeItem-4"><b>changeItem</b></a> ( int&nbsp;id, const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</li>
74<li class=fn>void changeItem ( const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;id ) &nbsp;<em>(obsolete)</em></li>
75<li class=fn>void changeItem ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, int&nbsp;id ) &nbsp;<em>(obsolete)</em></li>
76<li class=fn>void changeItem ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;icon, const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;id ) &nbsp;<em>(obsolete)</em></li>
77<li class=fn>bool <a href="#isItemActive"><b>isItemActive</b></a> ( int&nbsp;id ) const</li>
78<li class=fn>bool <a href="#isItemEnabled"><b>isItemEnabled</b></a> ( int&nbsp;id ) const</li>
79<li class=fn>void <a href="#setItemEnabled"><b>setItemEnabled</b></a> ( int&nbsp;id, bool&nbsp;enable )</li>
80<li class=fn>bool <a href="#isItemChecked"><b>isItemChecked</b></a> ( int&nbsp;id ) const</li>
81<li class=fn>void <a href="#setItemChecked"><b>setItemChecked</b></a> ( int&nbsp;id, bool&nbsp;check )</li>
82<li class=fn>bool <a href="#isItemVisible"><b>isItemVisible</b></a> ( int&nbsp;id ) const</li>
83<li class=fn>void <a href="#setItemVisible"><b>setItemVisible</b></a> ( int&nbsp;id, bool&nbsp;visible )</li>
84<li class=fn>virtual void <a href="#updateItem"><b>updateItem</b></a> ( int&nbsp;id )</li>
85<li class=fn>int <a href="#indexOf"><b>indexOf</b></a> ( int&nbsp;id ) const</li>
86<li class=fn>int <a href="#idAt"><b>idAt</b></a> ( int&nbsp;index ) const</li>
87<li class=fn>virtual void <a href="#setId"><b>setId</b></a> ( int&nbsp;index, int&nbsp;id )</li>
88<li class=fn>bool <a href="#connectItem"><b>connectItem</b></a> ( int&nbsp;id, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )</li>
89<li class=fn>bool <a href="#disconnectItem"><b>disconnectItem</b></a> ( int&nbsp;id, const&nbsp;QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )</li>
90<li class=fn>bool <a href="#setItemParameter"><b>setItemParameter</b></a> ( int&nbsp;id, int&nbsp;param )</li>
91<li class=fn>int <a href="#itemParameter"><b>itemParameter</b></a> ( int&nbsp;id ) const</li>
92<li class=fn>QMenuItem * <a href="#findItem"><b>findItem</b></a> ( int&nbsp;id ) const</li>
93<li class=fn>QMenuItem * <a href="#findItem-2"><b>findItem</b></a> ( int&nbsp;id, QMenuData&nbsp;**&nbsp;parent ) const</li>
94<li class=fn>virtual void <a href="#activateItemAt"><b>activateItemAt</b></a> ( int&nbsp;index )</li>
95</ul>
96<h2>Protected Members</h2>
97<ul>
98<li class=fn>virtual void <a href="#menuContentsChanged"><b>menuContentsChanged</b></a> ()</li>
99<li class=fn>virtual void <a href="#menuStateChanged"><b>menuStateChanged</b></a> ()</li>
100<li class=fn>virtual void <a href="#menuInsPopup"><b>menuInsPopup</b></a> ( QPopupMenu * )</li>
101<li class=fn>virtual void <a href="#menuDelPopup"><b>menuDelPopup</b></a> ( QPopupMenu * )</li>
102</ul>
103<hr><a name="details"></a><h2>Detailed Description</h2>
104
105
106The QMenuData class is a base class for <a href="qmenubar.html">QMenuBar</a> and <a href="qpopupmenu.html">QPopupMenu</a>.
107<p>
108<p> QMenuData has an internal list of menu items. A menu item can have
109a <a href="#text">text</a>(), an <a href="#accel">accelerator</a>, a <a href="#pixmap">pixmap</a>(), an
110<a href="#iconSet">iconSet</a>(), a <a href="#whatsThis">whatsThis</a>() text and a popup menu (unless it is a
111separator). Menu items may optionally be <a href="#setItemChecked">checked</a> (except for separators).
112<p> The menu item sends out an <a href="qmenubar.html#activated">activated()</a> signal when it is chosen and a <a href="qmenubar.html#highlighted">highlighted()</a> signal when it
113receives the user input focus.
114<p> <!-- index menu identifier --><a name="menu-identifier"></a>
115<p> Menu items are assigned the menu identifier <em>id</em> that is passed
116in <a href="#insertItem">insertItem</a>() or an automatically generated identifier if <em>id</em>
117is < 0 (the default). The generated identifiers (negative
118integers) are guaranteed to be unique within the entire
119application. The identifier is used to access the menu item in
120other functions.
121<p> Menu items can be removed with <a href="#removeItem">removeItem</a>() and <a href="#removeItemAt">removeItemAt</a>(), or
122changed with <a href="#changeItem">changeItem</a>(). All menu items can be removed with
123<a href="#clear">clear</a>(). Accelerators can be changed or set with <a href="#setAccel">setAccel</a>().
124Checkable items can be checked or unchecked with <a href="#setItemChecked">setItemChecked</a>().
125Items can be enabled or disabled using <a href="#setItemEnabled">setItemEnabled</a>() and
126connected and disconnected with <a href="#connectItem">connectItem</a>() and <a href="#disconnectItem">disconnectItem</a>()
127respectively. By default, newly created menu items are visible.
128They can be hidden (and shown again) with <a href="#setItemVisible">setItemVisible</a>().
129<p> Menu items are stored in a list. Use <a href="#findItem">findItem</a>() to find an item by
130its list position or by its menu identifier. (See also <a href="#indexOf">indexOf</a>()
131and <a href="#idAt">idAt</a>().)
132<p> <p>See also <a href="qaccel.html">QAccel</a>, <a href="qpopupmenu.html">QPopupMenu</a>, <a href="qaction.html">QAction</a>, and <a href="misc.html">Miscellaneous Classes</a>.
133
134<hr><h2>Member Function Documentation</h2>
135<h3 class=fn><a name="QMenuData"></a>QMenuData::QMenuData ()
136</h3>
137Constructs an empty menu data list.
138
139<h3 class=fn><a name="~QMenuData"></a>QMenuData::~QMenuData ()<tt> [virtual]</tt>
140</h3>
141Removes all menu items and disconnects any signals that have been
142connected.
143
144<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QMenuData::accel ( int&nbsp;id ) const
145</h3>
146Returns the accelerator key that has been defined for the menu
147item <em>id</em>, or 0 if it has no accelerator key or if there is no
148such menu item.
149<p> <p>See also <a href="#setAccel">setAccel</a>(), <a href="qaccel.html">QAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
150
151<h3 class=fn>void <a name="activateItemAt"></a>QMenuData::activateItemAt ( int&nbsp;index )<tt> [virtual]</tt>
152</h3>
153Activates the menu item at position <em>index</em>.
154<p> If the index is invalid (for example, -1), the object itself is
155deactivated.
156
157<h3 class=fn>void <a name="changeItem"></a>QMenuData::changeItem ( int&nbsp;id, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )
158</h3>
159Changes the text of the menu item <em>id</em> to <em>text</em>. If the item
160has an icon, the icon remains unchanged.
161<p> <p>See also <a href="#text">text</a>().
162
163<h3 class=fn>void <a name="changeItem-2"></a>QMenuData::changeItem ( int&nbsp;id, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
164</h3>
165This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
166<p> Changes the pixmap of the menu item <em>id</em> to the pixmap <em>pixmap</em>.
167If the item has an icon, the icon is unchanged.
168<p> <p>See also <a href="#pixmap">pixmap</a>().
169
170<h3 class=fn>void <a name="changeItem-3"></a>QMenuData::changeItem ( int&nbsp;id, const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )
171</h3>
172This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
173<p> Changes the iconset and text of the menu item <em>id</em> to the <em>icon</em>
174and <em>text</em> respectively.
175<p> <p>See also <a href="#pixmap">pixmap</a>().
176
177<h3 class=fn>void <a name="changeItem-4"></a>QMenuData::changeItem ( int&nbsp;id, const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap )
178</h3>
179This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
180<p> Changes the iconset and pixmap of the menu item <em>id</em> to <em>icon</em>
181and <em>pixmap</em> respectively.
182<p> <p>See also <a href="#pixmap">pixmap</a>().
183
184<h3 class=fn>void <a name="changeItem-5"></a>QMenuData::changeItem ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;id )
185</h3>
186
187<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
188<p> Changes the text of the menu item <em>id</em>. If the item has an icon,
189the icon remains unchanged.
190<p> <p>See also <a href="#text">text</a>().
191
192<h3 class=fn>void <a name="changeItem-6"></a>QMenuData::changeItem ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, int&nbsp;id )
193</h3>
194
195<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
196<p> Changes the pixmap of the menu item <em>id</em>. If the item has an icon,
197the icon remains unchanged.
198<p> <p>See also <a href="#pixmap">pixmap</a>().
199
200<h3 class=fn>void <a name="changeItem-7"></a>QMenuData::changeItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;id )
201</h3>
202
203<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
204<p> Changes the icon and text of the menu item <em>id</em>.
205<p> <p>See also <a href="#pixmap">pixmap</a>().
206
207<h3 class=fn>void <a name="clear"></a>QMenuData::clear ()
208</h3>
209Removes all menu items.
210<p> <p>See also <a href="#removeItem">removeItem</a>() and <a href="#removeItemAt">removeItemAt</a>().
211
212<p>Examples: <a href="mdi-example.html#x2029">mdi/application.cpp</a> and <a href="qwerty-example.html#x370">qwerty/qwerty.cpp</a>.
213<h3 class=fn>bool <a name="connectItem"></a>QMenuData::connectItem ( int&nbsp;id, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )
214</h3>
215Connects the menu item with identifier <em>id</em> to <em>receiver</em>'s <em>member</em> slot or signal.
216<p> The receiver's slot (or signal) is activated when the menu item is
217activated.
218<p> <p>See also <a href="#disconnectItem">disconnectItem</a>() and <a href="#setItemParameter">setItemParameter</a>().
219
220<p>Example: <a href="menu-example.html#x1868">menu/menu.cpp</a>.
221<h3 class=fn>uint <a name="count"></a>QMenuData::count () const
222</h3>
223Returns the number of items in the menu.
224
225<h3 class=fn>bool <a name="disconnectItem"></a>QMenuData::disconnectItem ( int&nbsp;id, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )
226</h3>
227Disconnects the <em>receiver</em>'s <em>member</em> from the menu item with
228identifier <em>id</em>.
229<p> All connections are removed when the menu data object is
230destroyed.
231<p> <p>See also <a href="#connectItem">connectItem</a>() and <a href="#setItemParameter">setItemParameter</a>().
232
233<h3 class=fn>QMenuItem * <a name="findItem"></a>QMenuData::findItem ( int&nbsp;id ) const
234</h3>
235Returns the menu item with identifier <em>id</em>, or 0 if there is no
236item with this identifier.
237<p> Note that QMenuItem is an internal class, and that you should not
238need to call this function. Use the higher level functions like
239<a href="#text">text</a>(), <a href="#pixmap">pixmap</a>() and <a href="#changeItem">changeItem</a>() to get and modify menu item
240attributes instead.
241<p> <p>See also <a href="#indexOf">indexOf</a>().
242
243<p>Example: <a href="canvas-chart-example.html#x2882">chart/chartform.cpp</a>.
244<h3 class=fn>QMenuItem * <a name="findItem-2"></a>QMenuData::findItem ( int&nbsp;id, <a href="qmenudata.html">QMenuData</a>&nbsp;**&nbsp;parent ) const
245</h3>
246This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
247<p> Returns the menu item with identifier <em>id</em>, or 0 if there is no
248item with this identifier. Changes <em>*parent</em> to point to the
249parent of the return value.
250<p> Note that QMenuItem is an internal class, and that you should not
251need to call this function. Use the higher level functions like
252<a href="#text">text</a>(), <a href="#pixmap">pixmap</a>() and <a href="#changeItem">changeItem</a>() to get and modify menu item
253attributes instead.
254<p> <p>See also <a href="#indexOf">indexOf</a>().
255
256<h3 class=fn><a href="qiconset.html">QIconSet</a>&nbsp;* <a name="iconSet"></a>QMenuData::iconSet ( int&nbsp;id ) const
257</h3>
258Returns the icon set that has been set for menu item <em>id</em>, or 0
259if no icon set has been set.
260<p> <p>See also <a href="#changeItem">changeItem</a>(), <a href="#text">text</a>(), and <a href="#pixmap">pixmap</a>().
261
262<h3 class=fn>int <a name="idAt"></a>QMenuData::idAt ( int&nbsp;index ) const
263</h3>
264Returns the identifier of the menu item at position <em>index</em> in
265the internal list, or -1 if <em>index</em> is out of range.
266<p> <p>See also <a href="#setId">setId</a>() and <a href="#indexOf">indexOf</a>().
267
268<h3 class=fn>int <a name="indexOf"></a>QMenuData::indexOf ( int&nbsp;id ) const
269</h3>
270Returns the index of the menu item with identifier <em>id</em>, or -1 if
271there is no item with this identifier.
272<p> <p>See also <a href="#idAt">idAt</a>() and <a href="#findItem">findItem</a>().
273
274<p>Example: <a href="scrollview-example.html#x633">scrollview/scrollview.cpp</a>.
275<h3 class=fn>int <a name="insertItem"></a>QMenuData::insertItem ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )
276</h3>
277The family of <a href="#insertItem">insertItem</a>() functions inserts menu items into a
278popup menu or a menu bar.
279<p> A menu item is usually either a text string or a pixmap, both with
280an optional icon or keyboard accelerator. For special cases it is
281also possible to insert custom items (see <a href="qcustommenuitem.html">QCustomMenuItem</a>) or
282even widgets into popup menus.
283<p> Some insertItem() members take a popup menu as an additional
284argument. Use this to insert submenus into existing menus or
285pulldown menus into a menu bar.
286<p> The number of insert functions may look confusing, but they are
287actually quite simple to use.
288<p> This default version inserts a menu item with the text <em>text</em>,
289the accelerator key <em>accel</em>, an id and an optional index and
290connects it to the slot <em>member</em> in the object <em>receiver</em>.
291<p> Example:
292<pre>
293 <a href="qmenubar.html">QMenuBar</a> *mainMenu = new <a href="qmenubar.html">QMenuBar</a>;
294 <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu = new <a href="qpopupmenu.html">QPopupMenu</a>;
295 fileMenu-&gt;<a href="#insertItem">insertItem</a>( "New", myView, SLOT(newFile()), CTRL+Key_N );
296 fileMenu-&gt;<a href="#insertItem">insertItem</a>( "Open", myView, SLOT(open()), CTRL+Key_O );
297 mainMenu-&gt;<a href="#insertItem">insertItem</a>( "File", fileMenu );
298 </pre>
299
300<p> Not all insert functions take an object/slot parameter or an
301accelerator key. Use <a href="#connectItem">connectItem</a>() and <a href="#setAccel">setAccel</a>() on those items.
302<p> If you need to translate accelerators, use tr() with the text and
303accelerator. (For translations use a string <a href="qkeysequence.html">key
304 sequence</a>.):
305<pre>
306 fileMenu-&gt;insertItem( tr("Open"), myView, SLOT(open()),
307 tr("Ctrl+O") );
308 </pre>
309
310<p> In the example above, pressing Ctrl+O or selecting "Open" from the
311menu activates the myView->open() function.
312<p> Some insert functions take a <a href="qiconset.html">QIconSet</a> parameter to specify the
313little menu item icon. Note that you can always pass a <a href="qpixmap.html">QPixmap</a>
314object instead.
315<p> The <em>id</em> specifies the identification number associated with the
316menu item. Note that only positive values are valid, as a negative
317value will make Qt select a unique id for the item.
318<p> The <em>index</em> specifies the position in the menu. The menu item is
319appended at the end of the list if <em>index</em> is negative.
320<p> Note that keyboard accelerators in Qt are not application-global,
321instead they are bound to a certain top-level window. For example,
322accelerators in <a href="qpopupmenu.html">QPopupMenu</a> items only work for menus that are
323associated with a certain window. This is true for popup menus
324that live in a menu bar since their accelerators will then be
325installed in the menu bar itself. This also applies to stand-alone
326popup menus that have a top-level widget in their parentWidget()
327chain. The menu will then install its accelerator object on that
328top-level widget. For all other cases use an independent <a href="qaccel.html">QAccel</a>
329object.
330<p> <b>Warning:</b> Be careful when passing a literal 0 to <a href="#insertItem">insertItem</a>()
331because some C++ compilers choose the wrong overloaded function.
332Cast the 0 to what you mean, e.g. <tt>(QObject*)0</tt>.
333<p> <b>Warning:</b> On Mac OS X, items that connect to a slot that are inserted into a
334menubar will not function as we use the native menubar that knows nothing
335about signals or slots. Instead insert the items into a popup menu and
336insert the popup menu into the menubar. This may be fixed in a future Qt
337version.
338<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
339<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), <a href="#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
340
341<p>Examples: <a href="addressbook-example.html#x569">addressbook/mainwindow.cpp</a>, <a href="canvas-example.html#x2936">canvas/canvas.cpp</a>, <a href="menu-example.html#x1869">menu/menu.cpp</a>, <a href="qwerty-example.html#x371">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x634">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x1327">showimg/showimg.cpp</a>, and <a href="sound-example.html#x2810">sound/sound.cpp</a>.
342<h3 class=fn>int <a name="insertItem-2"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )
343</h3>
344This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
345<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, accelerator
346<em>accel</em>, optional id <em>id</em>, and optional <em>index</em> position. The
347menu item is connected it to the <em>receiver</em>'s <em>member</em> slot. The
348icon will be displayed to the left of the text in the item.
349<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
350<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), <a href="#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
351
352<h3 class=fn>int <a name="insertItem-3"></a>QMenuData::insertItem ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )
353</h3>
354This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
355<p> Inserts a menu item with pixmap <em>pixmap</em>, accelerator <em>accel</em>,
356optional id <em>id</em>, and optional <em>index</em> position. The menu item
357is connected it to the <em>receiver</em>'s <em>member</em> slot. The icon will
358be displayed to the left of the text in the item.
359<p> To look best when being highlighted as a menu item, the pixmap
360should provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()).
361<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
362<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
363
364<h3 class=fn>int <a name="insertItem-4"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, const&nbsp;<a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member, const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;accel = 0, int&nbsp;id = -1, int&nbsp;index = -1 )
365</h3>
366This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
367<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>,
368accelerator <em>accel</em>, optional id <em>id</em>, and optional <em>index</em>
369position. The icon will be displayed to the left of the pixmap in
370the item. The item is connected to the <em>member</em> slot in the <em>receiver</em> object.
371<p> To look best when being highlighted as a menu item, the pixmap
372should provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()).
373<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
374<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), <a href="#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
375
376<h3 class=fn>int <a name="insertItem-5"></a>QMenuData::insertItem ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;id = -1, int&nbsp;index = -1 )
377</h3>
378This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
379<p> Inserts a menu item with text <em>text</em>, optional id <em>id</em>, and
380optional <em>index</em> position.
381<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
382<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
383
384<h3 class=fn>int <a name="insertItem-6"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;id = -1, int&nbsp;index = -1 )
385</h3>
386This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
387<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, optional id
388<em>id</em>, and optional <em>index</em> position. The icon will be displayed
389to the left of the text in the item.
390<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
391<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
392
393<h3 class=fn>int <a name="insertItem-7"></a>QMenuData::insertItem ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )
394</h3>
395This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
396<p> Inserts a menu item with text <em>text</em>, submenu <em>popup</em>, optional
397id <em>id</em>, and optional <em>index</em> position.
398<p> The <em>popup</em> must be deleted by the programmer or by its parent
399widget. It is not deleted when this menu item is removed or when
400the menu is deleted.
401<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
402<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
403
404<h3 class=fn>int <a name="insertItem-8"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )
405</h3>
406This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
407<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em> position. The icon
408will be displayed to the left of the text in the item.
409<p> The <em>popup</em> must be deleted by the programmer or by its parent
410widget. It is not deleted when this menu item is removed or when
411the menu is deleted.
412<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
413<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
414
415<h3 class=fn>int <a name="insertItem-9"></a>QMenuData::insertItem ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, int&nbsp;id = -1, int&nbsp;index = -1 )
416</h3>
417This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
418<p> Inserts a menu item with pixmap <em>pixmap</em>, optional id <em>id</em>, and
419optional <em>index</em> position.
420<p> To look best when being highlighted as a menu item, the pixmap
421should provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()).
422<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
423<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
424
425<h3 class=fn>int <a name="insertItem-a"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, int&nbsp;id = -1, int&nbsp;index = -1 )
426</h3>
427This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
428<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>, optional
429id <em>id</em>, and optional <em>index</em> position. The icon will be
430displayed to the left of the pixmap in the item.
431<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
432<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
433
434<h3 class=fn>int <a name="insertItem-b"></a>QMenuData::insertItem ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )
435</h3>
436This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
437<p> Inserts a menu item with pixmap <em>pixmap</em>, submenu <em>popup</em>,
438optional id <em>id</em>, and optional <em>index</em> position.
439<p> The <em>popup</em> must be deleted by the programmer or by its parent
440widget. It is not deleted when this menu item is removed or when
441the menu is deleted.
442<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
443<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
444
445<h3 class=fn>int <a name="insertItem-c"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;*&nbsp;popup, int&nbsp;id = -1, int&nbsp;index = -1 )
446</h3>
447This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
448<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em> submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em> position. The icon
449will be displayed to the left of the pixmap in the item.
450<p> The <em>popup</em> must be deleted by the programmer or by its parent
451widget. It is not deleted when this menu item is removed or when
452the menu is deleted.
453<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
454<p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), and <a href="#connectItem">connectItem</a>().
455
456<h3 class=fn>int <a name="insertItem-d"></a>QMenuData::insertItem ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;widget, int&nbsp;id = -1, int&nbsp;index = -1 )
457</h3>
458This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
459<p> Inserts a menu item that consists of the widget <em>widget</em> with
460optional id <em>id</em>, and optional <em>index</em> position.
461<p> Ownership of <em>widget</em> is transferred to the popup menu or to the
462menu bar.
463<p> Theoretically, any widget can be inserted into a popup menu. In
464practice, this only makes sense with certain widgets.
465<p> If a widget is not focus-enabled (see
466<a href="qwidget.html#isFocusEnabled">QWidget::isFocusEnabled</a>()), the menu treats it as a separator;
467this means that the item is not selectable and will never get
468focus. In this way you can, for example, simply insert a <a href="qlabel.html">QLabel</a> if
469you need a popup menu with a title.
470<p> If the widget is focus-enabled it will get focus when the user
471traverses the popup menu with the arrow keys. If the widget does
472not accept <tt>ArrowUp</tt> and <tt>ArrowDown</tt> in its key event handler,
473the focus will move back to the menu when the respective arrow key
474is hit one more time. This works with a <a href="qlineedit.html">QLineEdit</a>, for example. If
475the widget accepts the arrow key itself, it must also provide the
476possibility to put the focus back on the menu again by calling
477<a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>(). Futhermore, if the embedded widget
478closes the menu when the user made a selection, this can be done
479safely by calling:
480<pre>
481 if ( isVisible() &amp;&amp;
482 parentWidget() &amp;&amp;
483 parentWidget()-&gt;inherits("QPopupMenu") )
484 parentWidget()-&gt;close();
485 </pre>
486
487<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
488<p> <p>See also <a href="#removeItem">removeItem</a>().
489
490<h3 class=fn>int <a name="insertItem-e"></a>QMenuData::insertItem ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;icon, <a href="qcustommenuitem.html">QCustomMenuItem</a>&nbsp;*&nbsp;custom, int&nbsp;id = -1, int&nbsp;index = -1 )
491</h3>
492This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
493<p> Inserts a custom menu item <em>custom</em> with an <em>icon</em> and with
494optional id <em>id</em>, and optional <em>index</em> position.
495<p> This only works with popup menus. It is not supported for menu
496bars. Ownership of <em>custom</em> is transferred to the popup menu.
497<p> If you want to connect a custom item to a slot, use <a href="#connectItem">connectItem</a>().
498<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
499<p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#removeItem">removeItem</a>(), and <a href="qcustommenuitem.html">QCustomMenuItem</a>.
500
501<h3 class=fn>int <a name="insertItem-f"></a>QMenuData::insertItem ( <a href="qcustommenuitem.html">QCustomMenuItem</a>&nbsp;*&nbsp;custom, int&nbsp;id = -1, int&nbsp;index = -1 )
502</h3>
503This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
504<p> Inserts a custom menu item <em>custom</em> with optional id <em>id</em>, and
505optional <em>index</em> position.
506<p> This only works with popup menus. It is not supported for menu
507bars. Ownership of <em>custom</em> is transferred to the popup menu.
508<p> If you want to connect a custom item to a slot, use <a href="#connectItem">connectItem</a>().
509<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
510<p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#removeItem">removeItem</a>(), and <a href="qcustommenuitem.html">QCustomMenuItem</a>.
511
512<h3 class=fn>int <a name="insertSeparator"></a>QMenuData::insertSeparator ( int&nbsp;index = -1 )
513</h3>
514Inserts a separator at position <em>index</em>, and returns the <a href="qmenudata.html#menu-identifier">menu identifier</a>
515number allocated to it. The separator becomes the last menu item if
516<em>index</em> is negative.
517<p> In a popup menu a separator is rendered as a horizontal line. In a
518<a href="motif-extension.html#Motif">Motif</a> menu bar a separator is spacing, so the rest of the items
519(normally just "Help") are drawn right-justified. In a Windows
520menu bar separators are ignored (to comply with the Windows style
521guidelines).
522
523<p>Examples: <a href="addressbook-example.html#x570">addressbook/mainwindow.cpp</a>, <a href="menu-example.html#x1870">menu/menu.cpp</a>, <a href="progress-example.html#x69">progress/progress.cpp</a>, <a href="qwerty-example.html#x372">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x635">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x1328">showimg/showimg.cpp</a>, and <a href="sound-example.html#x2811">sound/sound.cpp</a>.
524<h3 class=fn>bool <a name="isItemActive"></a>QMenuData::isItemActive ( int&nbsp;id ) const
525</h3>
526Returns TRUE if the menu item with the id <em>id</em> is currently
527active; otherwise returns FALSE.
528
529<h3 class=fn>bool <a name="isItemChecked"></a>QMenuData::isItemChecked ( int&nbsp;id ) const
530</h3>
531Returns TRUE if the menu item with the id <em>id</em> has been checked;
532otherwise returns FALSE.
533<p> <p>See also <a href="#setItemChecked">setItemChecked</a>().
534
535<p>Examples: <a href="canvas-example.html#x2938">canvas/canvas.cpp</a>, <a href="progress-example.html#x70">progress/progress.cpp</a>, and <a href="showimg-example.html#x1329">showimg/showimg.cpp</a>.
536<h3 class=fn>bool <a name="isItemEnabled"></a>QMenuData::isItemEnabled ( int&nbsp;id ) const
537</h3>
538Returns TRUE if the item with identifier <em>id</em> is enabled;
539otherwise returns FALSE
540<p> <p>See also <a href="#setItemEnabled">setItemEnabled</a>() and <a href="#isItemVisible">isItemVisible</a>().
541
542<h3 class=fn>bool <a name="isItemVisible"></a>QMenuData::isItemVisible ( int&nbsp;id ) const
543</h3>
544Returns TRUE if the menu item with the id <em>id</em> is visible;
545otherwise returns FALSE.
546<p> <p>See also <a href="#setItemVisible">setItemVisible</a>().
547
548<h3 class=fn>int <a name="itemParameter"></a>QMenuData::itemParameter ( int&nbsp;id ) const
549</h3>
550Returns the parameter of the activation signal of item <em>id</em>.
551<p> If no parameter has been specified for this item with
552<a href="#setItemParameter">setItemParameter</a>(), the value defaults to <em>id</em>.
553<p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#disconnectItem">disconnectItem</a>(), and <a href="#setItemParameter">setItemParameter</a>().
554
555<h3 class=fn>void <a name="menuContentsChanged"></a>QMenuData::menuContentsChanged ()<tt> [virtual protected]</tt>
556</h3>
557Virtual function; notifies subclasses that one or more items have
558been inserted or removed.
559
560<p>Reimplemented in <a href="qmenubar.html#menuContentsChanged">QMenuBar</a>.
561<h3 class=fn>void <a name="menuDelPopup"></a>QMenuData::menuDelPopup ( <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;* )<tt> [virtual protected]</tt>
562</h3>
563Virtual function; notifies subclasses that a popup menu item has
564been removed.
565
566<h3 class=fn>void <a name="menuInsPopup"></a>QMenuData::menuInsPopup ( <a href="qpopupmenu.html">QPopupMenu</a>&nbsp;* )<tt> [virtual protected]</tt>
567</h3>
568Virtual function; notifies subclasses that a popup menu item has
569been inserted.
570
571<h3 class=fn>void <a name="menuStateChanged"></a>QMenuData::menuStateChanged ()<tt> [virtual protected]</tt>
572</h3>
573Virtual function; notifies subclasses that one or more items have
574changed state (enabled/disabled or checked/unchecked).
575
576<p>Reimplemented in <a href="qmenubar.html#menuStateChanged">QMenuBar</a>.
577<h3 class=fn><a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="pixmap"></a>QMenuData::pixmap ( int&nbsp;id ) const
578</h3>
579Returns the pixmap that has been set for menu item <em>id</em>, or 0 if
580no pixmap has been set.
581<p> <p>See also <a href="#changeItem">changeItem</a>(), <a href="#text">text</a>(), and <a href="#iconSet">iconSet</a>().
582
583<h3 class=fn>void <a name="removeItem"></a>QMenuData::removeItem ( int&nbsp;id )
584</h3>
585
586<p> Removes the menu item that has the identifier <em>id</em>.
587<p> <p>See also <a href="#removeItemAt">removeItemAt</a>() and <a href="#clear">clear</a>().
588
589<p>Example: <a href="canvas-chart-example.html#x2885">chart/chartform.cpp</a>.
590<h3 class=fn>void <a name="removeItemAt"></a>QMenuData::removeItemAt ( int&nbsp;index )
591</h3>
592Removes the menu item at position <em>index</em>.
593<p> <p>See also <a href="#removeItem">removeItem</a>() and <a href="#clear">clear</a>().
594
595<h3 class=fn>void <a name="setAccel"></a>QMenuData::setAccel ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;key, int&nbsp;id )
596</h3>
597Sets the accelerator key for the menu item <em>id</em> to <em>key</em>.
598<p> An accelerator key consists of a key code and a combination of the
599modifiers <tt>SHIFT</tt>, <tt>CTRL</tt>, <tt>ALT</tt> or <tt>UNICODE_ACCEL</tt> (OR'ed or
600added). The header file <a href="qnamespace-h.html">qnamespace.h</a> contains a list of key
601codes.
602<p> Defining an accelerator key produces a text that is added to the
603menu item; for instance, <tt>CTRL</tt> + <tt>Key_O</tt> produces "Ctrl+O". The
604text is formatted differently for different platforms.
605<p> Note that keyboard accelerators in Qt are not application-global,
606instead they are bound to a certain top-level window. For example,
607accelerators in <a href="qpopupmenu.html">QPopupMenu</a> items only work for menus that are
608associated with a certain window. This is true for popup menus
609that live in a menu bar since their accelerators will then be
610installed in the menu bar itself. This also applies to stand-alone
611popup menus that have a top-level widget in their parentWidget()
612chain. The menu will then install its accelerator object on that
613top-level widget. For all other cases use an independent <a href="qaccel.html">QAccel</a>
614object.
615<p> Example:
616<pre>
617 <a href="qmenubar.html">QMenuBar</a> *mainMenu = new <a href="qmenubar.html">QMenuBar</a>;
618 <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu = new <a href="qpopupmenu.html">QPopupMenu</a>; // file sub menu
619 fileMenu-&gt;<a href="#insertItem">insertItem</a>( "Open Document", 67 ); // add "Open" item
620 fileMenu-&gt;<a href="#setAccel">setAccel</a>( CTRL + Key_O, 67 ); // Ctrl+O to open
621 fileMenu-&gt;<a href="#insertItem">insertItem</a>( "Quit", 69 ); // add "Quit" item
622 fileMenu-&gt;<a href="#setAccel">setAccel</a>( CTRL + ALT + Key_Delete, 69 ); // add Alt+Del to quit
623 mainMenu-&gt;<a href="#insertItem">insertItem</a>( "File", fileMenu ); // add the file menu
624 </pre>
625
626<p> If you need to translate accelerators, use tr() with a string:
627<pre>
628 fileMenu-&gt;setAccel( tr("Ctrl+O"), 67 );
629 </pre>
630
631<p> You can also specify the accelerator in the <a href="#insertItem">insertItem</a>() function.
632You may prefer to use <a href="qaction.html">QAction</a> to associate accelerators with menu
633items.
634<p> <p>See also <a href="#accel">accel</a>(), <a href="#insertItem">insertItem</a>(), <a href="qaccel.html">QAccel</a>, and <a href="qaction.html">QAction</a>.
635
636<p>Example: <a href="menu-example.html#x1871">menu/menu.cpp</a>.
637<h3 class=fn>void <a name="setId"></a>QMenuData::setId ( int&nbsp;index, int&nbsp;id )<tt> [virtual]</tt>
638</h3>
639Sets the <a href="qmenudata.html#menu-identifier">menu identifier</a> of the item at <em>index</em> to <em>id</em>.
640<p> If <em>index</em> is out of range, the operation is ignored.
641<p> <p>See also <a href="#idAt">idAt</a>().
642
643<h3 class=fn>void <a name="setItemChecked"></a>QMenuData::setItemChecked ( int&nbsp;id, bool&nbsp;check )
644</h3>
645If <em>check</em> is TRUE, checks the menu item with id <em>id</em>; otherwise
646unchecks the menu item with id <em>id</em>. Calls
647<a href="qpopupmenu.html#setCheckable">QPopupMenu::setCheckable</a>( TRUE ) if necessary.
648<p> <p>See also <a href="#isItemChecked">isItemChecked</a>().
649
650<p>Examples: <a href="canvas-example.html#x2939">canvas/canvas.cpp</a>, <a href="grapher-nsplugin-example.html#x2749">grapher/grapher.cpp</a>, <a href="mdi-example.html#x2032">mdi/application.cpp</a>, <a href="menu-example.html#x1872">menu/menu.cpp</a>, <a href="progress-example.html#x71">progress/progress.cpp</a>, <a href="scrollview-example.html#x636">scrollview/scrollview.cpp</a>, and <a href="showimg-example.html#x1330">showimg/showimg.cpp</a>.
651<h3 class=fn>void <a name="setItemEnabled"></a>QMenuData::setItemEnabled ( int&nbsp;id, bool&nbsp;enable )
652</h3>
653If <em>enable</em> is TRUE, enables the menu item with identifier <em>id</em>;
654otherwise disables the menu item with identifier <em>id</em>.
655<p> <p>See also <a href="#isItemEnabled">isItemEnabled</a>().
656
657<p>Examples: <a href="mdi-example.html#x2033">mdi/application.cpp</a>, <a href="menu-example.html#x1873">menu/menu.cpp</a>, <a href="progress-example.html#x72">progress/progress.cpp</a>, and <a href="showimg-example.html#x1331">showimg/showimg.cpp</a>.
658<h3 class=fn>bool <a name="setItemParameter"></a>QMenuData::setItemParameter ( int&nbsp;id, int&nbsp;param )
659</h3>
660Sets the parameter of the activation signal of item <em>id</em> to <em>param</em>.
661<p> If any receiver takes an integer parameter, this value is passed.
662<p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#disconnectItem">disconnectItem</a>(), and <a href="#itemParameter">itemParameter</a>().
663
664<p>Example: <a href="mdi-example.html#x2034">mdi/application.cpp</a>.
665<h3 class=fn>void <a name="setItemVisible"></a>QMenuData::setItemVisible ( int&nbsp;id, bool&nbsp;visible )
666</h3>
667If <em>visible</em> is TRUE, shows the menu item with id <em>id</em>; otherwise
668hides the menu item with id <em>id</em>.
669<p> <p>See also <a href="#isItemVisible">isItemVisible</a>() and <a href="#isItemEnabled">isItemEnabled</a>().
670
671<h3 class=fn>void <a name="setWhatsThis"></a>QMenuData::setWhatsThis ( int&nbsp;id, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )
672</h3>
673Sets <em>text</em> as What's This help for the menu item with identifier
674<em>id</em>.
675<p> <p>See also <a href="#whatsThis">whatsThis</a>().
676
677<p>Examples: <a href="simple-application-example.html#x1554">application/application.cpp</a>, <a href="helpsystem-example.html#x2689">helpsystem/mainwindow.cpp</a>, and <a href="mdi-example.html#x2035">mdi/application.cpp</a>.
678<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QMenuData::text ( int&nbsp;id ) const
679</h3>
680Returns the text that has been set for menu item <em>id</em>, or
681<a href="qstring.html#QString-null">QString::null</a> if no text has been set.
682<p> <p>See also <a href="#changeItem">changeItem</a>(), <a href="#pixmap">pixmap</a>(), and <a href="#iconSet">iconSet</a>().
683
684<p>Examples: <a href="qdir-example.html#x1831">qdir/qdir.cpp</a> and <a href="showimg-example.html#x1332">showimg/showimg.cpp</a>.
685<h3 class=fn>void <a name="updateItem"></a>QMenuData::updateItem ( int&nbsp;id )<tt> [virtual]</tt>
686</h3>
687Virtual function; notifies subclasses about an item with <em>id</em>
688that has been changed.
689
690<p>Reimplemented in <a href="qpopupmenu.html#updateItem">QPopupMenu</a>.
691<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QMenuData::whatsThis ( int&nbsp;id ) const
692</h3>
693Returns the What's This help text for the item with identifier <em>id</em> or <a href="qstring.html#QString-null">QString::null</a> if no text has yet been defined.
694<p> <p>See also <a href="#setWhatsThis">setWhatsThis</a>().
695
696<!-- eof -->
697<hr><p>
698This file is part of the <a href="index.html">Qt toolkit</a>.
699Copyright &copy; 1995-2007
700<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
701<table width=100% cellspacing=0 border=0><tr>
702<td>Copyright &copy; 2007
703<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
704<td align=right><div align=right>Qt 3.3.8</div>
705</table></div></address></body>
706</html>
Note: See TracBrowser for help on using the repository browser.