<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>TQMenuData Class Reference</h1>
<p>The TQMenuData class is a base class for TQMenuBar and TQPopupMenu.
The TQMenuData class is a base class for <ahref="qmenubar.html">TQMenuBar</a> and <ahref="qpopupmenu.html">TQPopupMenu</a>.
<p>
<p> TQMenuData has an internal list of menu items. A menu item can have
a <ahref="#text">text</a>(), an <ahref="#accel">accelerator</a>, a <ahref="#pixmap">pixmap</a>(), an
<ahref="#iconSet">iconSet</a>(), a <ahref="#whatsThis">whatsThis</a>() text and a popup menu (unless it is a
separator). Menu items may optionally be <ahref="#setItemChecked">checked</a> (except for separators).
<p> The menu item sends out an <ahref="qmenubar.html#activated">activated()</a> signal when it is chosen and a <ahref="qmenubar.html#highlighted">highlighted()</a> signal when it
receives the user input focus.
<p><!-- index menu identifier --><aname="menu-identifier"></a>
<p> Menu items are assigned the menu identifier <em>id</em> that is passed
in <ahref="#insertItem">insertItem</a>() or an automatically generated identifier if <em>id</em>
is <0(thedefault).Thegeneratedidentifiers(negative
integers) are guaranteed to be unique within the entire
application. The identifier is used to access the menu item in
other functions.
<p> Menu items can be removed with <ahref="#removeItem">removeItem</a>() and <ahref="#removeItemAt">removeItemAt</a>(), or
changed with <ahref="#changeItem">changeItem</a>(). All menu items can be removed with
<ahref="#clear">clear</a>(). Accelerators can be changed or set with <ahref="#setAccel">setAccel</a>().
Checkable items can be checked or unchecked with <ahref="#setItemChecked">setItemChecked</a>().
Items can be enabled or disabled using <ahref="#setItemEnabled">setItemEnabled</a>() and
connected and disconnected with <ahref="#connectItem">connectItem</a>() and <ahref="#disconnectItem">disconnectItem</a>()
respectively. By default, newly created menu items are visible.
They can be hidden (and shown again) with <ahref="#setItemVisible">setItemVisible</a>().
<p> Menu items are stored in a list. Use <ahref="#findItem">findItem</a>() to find an item by
its list position or by its menu identifier. (See also <ahref="#indexOf">indexOf</a>()
and <ahref="#idAt">idAt</a>().)
<p><p>See also <ahref="qaccel.html">TQAccel</a>, <ahref="qpopupmenu.html">TQPopupMenu</a>, <ahref="qaction.html">TQAction</a>, and <ahref="misc.html">Miscellaneous Classes</a>.
<p> In the example above, pressing Ctrl+O or selecting "Open" from the
menu activates the myView->open() function.
<p> Some insert functions take a <ahref="qiconset.html">TQIconSet</a> parameter to specify the
little menu item icon. Note that you can always pass a <ahref="qpixmap.html">TQPixmap</a>
object instead.
<p> The <em>id</em> specifies the identification number associated with the
menu item. Note that only positive values are valid, as a negative
value will make TQt select a unique id for the item.
<p> The <em>index</em> specifies the position in the menu. The menu item is
appended at the end of the list if <em>index</em> is negative.
<p> Note that keyboard accelerators in TQt are not application-global,
instead they are bound to a certain top-level window. For example,
accelerators in <ahref="qpopupmenu.html">TQPopupMenu</a> items only work for menus that are
associated with a certain window. This is true for popup menus
that live in a menu bar since their accelerators will then be
installed in the menu bar itself. This also applies to stand-alone
popup menus that have a top-level widget in their parentWidget()
chain. The menu will then install its accelerator object on that
top-level widget. For all other cases use an independent <ahref="qaccel.html">TQAccel</a>
object.
<p><b>Warning:</b> Be careful when passing a literal 0 to <ahref="#insertItem">insertItem</a>()
because some C++ compilers choose the wrong overloaded function.
Cast the 0 to what you mean, e.g. <tt>(TQObject*)0</tt>.
<p><b>Warning:</b> On Mac OS X, items that connect to a slot that are inserted into a
menubar will not function as we use the native menubar that knows nothing
about signals or slots. Instead insert the items into a popup menu and
insert the popup menu into the menubar. This may be fixed in a future TQt
version.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), <ahref="#connectItem">connectItem</a>(), <ahref="qaccel.html">TQAccel</a>, and <ahref="qnamespace-h.html">qnamespace.h</a>.
<p>Examples: <ahref="addressbook-example.html#x569">addressbook/mainwindow.cpp</a>, <ahref="canvas-example.html#x2936">canvas/canvas.cpp</a>, <ahref="menu-example.html#x1869">menu/menu.cpp</a>, <ahref="qwerty-example.html#x371">qwerty/qwerty.cpp</a>, <ahref="scrollview-example.html#x634">scrollview/scrollview.cpp</a>, <ahref="showimg-example.html#x1327">showimg/showimg.cpp</a>, and <ahref="sound-example.html#x2810">sound/sound.cpp</a>.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, accelerator
<em>accel</em>, optional id <em>id</em>, and optional <em>index</em> position. The
menu item is connected it to the <em>receiver</em>'s <em>member</em> slot. The
icon will be displayed to the left of the text in the item.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), <ahref="#connectItem">connectItem</a>(), <ahref="qaccel.html">TQAccel</a>, and <ahref="qnamespace-h.html">qnamespace.h</a>.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with pixmap <em>pixmap</em>, accelerator <em>accel</em>,
optional id <em>id</em>, and optional <em>index</em> position. The menu item
is connected it to the <em>receiver</em>'s <em>member</em> slot. The icon will
be displayed to the left of the text in the item.
<p> To look best when being highlighted as a menu item, the pixmap
should provide a mask (see <ahref="qpixmap.html#mask">TQPixmap::mask</a>()).
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>,
accelerator <em>accel</em>, optional id <em>id</em>, and optional <em>index</em>
position. The icon will be displayed to the left of the pixmap in
the item. The item is connected to the <em>member</em> slot in the <em>receiver</em> object.
<p> To look best when being highlighted as a menu item, the pixmap
should provide a mask (see <ahref="qpixmap.html#mask">TQPixmap::mask</a>()).
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), <ahref="#connectItem">connectItem</a>(), <ahref="qaccel.html">TQAccel</a>, and <ahref="qnamespace-h.html">qnamespace.h</a>.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with text <em>text</em>, optional id <em>id</em>, and
optional <em>index</em> position.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, optional id
<em>id</em>, and optional <em>index</em> position. The icon will be displayed
to the left of the text in the item.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with text <em>text</em>, submenu <em>popup</em>, optional
id <em>id</em>, and optional <em>index</em> position.
<p> The <em>popup</em> must be deleted by the programmer or by its parent
widget. It is not deleted when this menu item is removed or when
the menu is deleted.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<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
will be displayed to the left of the text in the item.
<p> The <em>popup</em> must be deleted by the programmer or by its parent
widget. It is not deleted when this menu item is removed or when
the menu is deleted.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with pixmap <em>pixmap</em>, optional id <em>id</em>, and
optional <em>index</em> position.
<p> To look best when being highlighted as a menu item, the pixmap
should provide a mask (see <ahref="qpixmap.html#mask">TQPixmap::mask</a>()).
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>, optional
id <em>id</em>, and optional <em>index</em> position. The icon will be
displayed to the left of the pixmap in the item.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with pixmap <em>pixmap</em>, submenu <em>popup</em>,
optional id <em>id</em>, and optional <em>index</em> position.
<p> The <em>popup</em> must be deleted by the programmer or by its parent
widget. It is not deleted when this menu item is removed or when
the menu is deleted.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<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
will be displayed to the left of the pixmap in the item.
<p> The <em>popup</em> must be deleted by the programmer or by its parent
widget. It is not deleted when this menu item is removed or when
the menu is deleted.
<p> Returns the allocated <ahref="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p><p>See also <ahref="#removeItem">removeItem</a>(), <ahref="#changeItem">changeItem</a>(), <ahref="#setAccel">setAccel</a>(), and <ahref="#connectItem">connectItem</a>().
Returns TRUE if the menu item with the id <em>id</em> has been checked;
otherwise returns FALSE.
<p><p>See also <ahref="#setItemChecked">setItemChecked</a>().
<p>Examples: <ahref="canvas-example.html#x2938">canvas/canvas.cpp</a>, <ahref="progress-example.html#x70">progress/progress.cpp</a>, and <ahref="showimg-example.html#x1329">showimg/showimg.cpp</a>.
Returns the parameter of the activation signal of item <em>id</em>.
<p> If no parameter has been specified for this item with
<ahref="#setItemParameter">setItemParameter</a>(), the value defaults to <em>id</em>.
<p><p>See also <ahref="#connectItem">connectItem</a>(), <ahref="#disconnectItem">disconnectItem</a>(), and <ahref="#setItemParameter">setItemParameter</a>().
mainMenu-><ahref="#insertItem">insertItem</a>( "File", fileMenu ); // add the file menu
</pre>
<p> If you need to translate accelerators, use tr() with a string:
<pre>
fileMenu->setAccel( tr("Ctrl+O"), 67 );
</pre>
<p> You can also specify the accelerator in the <ahref="#insertItem">insertItem</a>() function.
You may prefer to use <ahref="qaction.html">TQAction</a> to associate accelerators with menu
items.
<p><p>See also <ahref="#accel">accel</a>(), <ahref="#insertItem">insertItem</a>(), <ahref="qaccel.html">TQAccel</a>, and <ahref="qaction.html">TQAction</a>.
Sets the parameter of the activation signal of item <em>id</em> to <em>param</em>.
<p> If any receiver takes an integer parameter, this value is passed.
<p><p>See also <ahref="#connectItem">connectItem</a>(), <ahref="#disconnectItem">disconnectItem</a>(), and <ahref="#itemParameter">itemParameter</a>().
Sets <em>text</em> as What's This help for the menu item with identifier
<em>id</em>.
<p><p>See also <ahref="#whatsThis">whatsThis</a>().
<p>Examples: <ahref="simple-application-example.html#x1554">application/application.cpp</a>, <ahref="helpsystem-example.html#x2689">helpsystem/mainwindow.cpp</a>, and <ahref="mdi-example.html#x2035">mdi/application.cpp</a>.
Returns the What's This help text for the item with identifier <em>id</em> or <ahref="qstring.html#TQString-null">TQString::null</a> if no text has yet been defined.
<p><p>See also <ahref="#setWhatsThis">setWhatsThis</a>().
<!-- eof -->
<hr><p>
This file is part of the <ahref="index.html">TQt toolkit</a>.