Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1642

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/widgets/qpopupmenu.cpp:120 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QPopupMenu 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: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPopupMenu Class Reference</h1>

<p>The QPopupMenu class provides a popup menu widget.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.h</a>&gt;</tt>
<p>Inherits <a href="qframe.html">QFrame</a> and <a href="qmenudata.html">QMenuData</a>.
<p><a href="qpopupmenu-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QPopupMenu"><b>QPopupMenu</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li>
<li><div class=fn><a href="#~QPopupMenu"><b>~QPopupMenu</b></a> ()</div></li>
<li><div class=fn>void <a href="#popup"><b>popup</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos, int&nbsp;indexAtPoint = 0 )</div></li>
<li><div class=fn>virtual void <a href="#updateItem"><b>updateItem</b></a> ( int&nbsp;id )</div></li>
<li><div class=fn>virtual void <a href="#setCheckable"><b>setCheckable</b></a> ( bool )</div></li>
<li><div class=fn>bool <a href="#isCheckable"><b>isCheckable</b></a> () const</div></li>
<li><div class=fn>int <a href="#exec"><b>exec</b></a> ()</div></li>
<li><div class=fn>int <a href="#exec-2"><b>exec</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos, int&nbsp;indexAtPoint = 0 )</div></li>
<li><div class=fn>virtual void <a href="#setActiveItem"><b>setActiveItem</b></a> ( int&nbsp;i )</div></li>
<li><div class=fn>int <a href="#idAt"><b>idAt</b></a> ( int&nbsp;index ) const</div></li>
<li><div class=fn>int <a href="#idAt-2"><b>idAt</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;pos ) const</div></li>
<li><div class=fn>int <a href="#insertTearOffHandle"><b>insertTearOffHandle</b></a> ( int&nbsp;id = -1, int&nbsp;index = -1 )</div></li>
</ul>
<h2>Signals</h2>
<ul>
<li><div class=fn>void <a href="#activated"><b>activated</b></a> ( int&nbsp;id )</div></li>
<li><div class=fn>void <a href="#highlighted"><b>highlighted</b></a> ( int&nbsp;id )</div></li>
<li><div class=fn>void <a href="#aboutToShow"><b>aboutToShow</b></a> ()</div></li>
<li><div class=fn>void <a href="#aboutToHide"><b>aboutToHide</b></a> ()</div></li>
</ul>
<h2>Important Inherited Members</h2>
<ul>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div class=fn>int <a href="#insertItem-d"><b>insertItem</b></a> ( QWidget&nbsp;*&nbsp;widget, int&nbsp;id = -1, int&nbsp;index = -1 )</div></li>
<li><div 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 )</div></li>
<li><div class=fn>int <a href="#insertItem-f"><b>insertItem</b></a> ( QCustomMenuItem&nbsp;*&nbsp;custom, int&nbsp;id = -1, int&nbsp;index = -1 )</div></li>
<li><div class=fn>int <a href="#insertSeparator"><b>insertSeparator</b></a> ( int&nbsp;index = -1 )</div></li>
<li><div class=fn>void <a href="#removeItem"><b>removeItem</b></a> ( int&nbsp;id )</div></li>
<li><div class=fn>void <a href="#removeItemAt"><b>removeItemAt</b></a> ( int&nbsp;index )</div></li>
<li><div class=fn>void <a href="#clear"><b>clear</b></a> ()</div></li>
<li><div class=fn>QKeySequence <a href="#accel"><b>accel</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>void <a href="#setAccel"><b>setAccel</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;key, int&nbsp;id )</div></li>
<li><div class=fn>QIconSet * <a href="#iconSet"><b>iconSet</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>QString <a href="#text"><b>text</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>QPixmap * <a href="#pixmap"><b>pixmap</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( int&nbsp;id, const&nbsp;QString&nbsp;&amp;&nbsp;text )</div></li>
<li><div class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>void <a href="#changeItem"><b>changeItem</b></a> ( int&nbsp;id, const&nbsp;QString&nbsp;&amp;&nbsp;text )</div></li>
<li><div class=fn>void <a href="#changeItem-2"><b>changeItem</b></a> ( int&nbsp;id, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div class=fn>bool <a href="#isItemEnabled"><b>isItemEnabled</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>void <a href="#setItemEnabled"><b>setItemEnabled</b></a> ( int&nbsp;id, bool&nbsp;enable )</div></li>
<li><div class=fn>bool <a href="#isItemChecked"><b>isItemChecked</b></a> ( int&nbsp;id ) const</div></li>
<li><div class=fn>void <a href="#setItemChecked"><b>setItemChecked</b></a> ( int&nbsp;id, bool&nbsp;check )</div></li>
<li><div 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 )</div></li>
<li><div 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 )</div></li>
<li><div class=fn>bool <a href="#setItemParameter"><b>setItemParameter</b></a> ( int&nbsp;id, int&nbsp;param )</div></li>
<li><div class=fn>int <a href="#itemParameter"><b>itemParameter</b></a> ( int&nbsp;id ) const</div></li>
</ul>
<h2>Properties</h2>
<ul>
<li><div class=fn>bool <a href="#checkable-prop"><b>checkable</b></a>&nbsp;- whether the display of check marks on menu items is enabled</div></li>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class=fn>int <a href="#itemHeight"><b>itemHeight</b></a> ( int&nbsp;row ) const</div></li>
<li><div class=fn>int <a href="#itemHeight-2"><b>itemHeight</b></a> ( QMenuItem&nbsp;*&nbsp;mi ) const</div></li>
<li><div class=fn>void <a href="#drawItem"><b>drawItem</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;tab_, QMenuItem&nbsp;*&nbsp;mi, bool&nbsp;act, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )</div></li>
<li><div class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter&nbsp;*&nbsp;p )</div></li>
<li><div class=fn>int <a href="#columns"><b>columns</b></a> () const</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QPopupMenu class provides a popup menu widget.
<p> 


<p> A popup menu widget is a selection menu. It can be either a pull-down
menu in a menu bar or a standalone context (popup) menu.  Pull-down menus
are shown by the menu bar when the user clicks on the respective
item or hits the specified shortcut key. Use <a href="qmenudata.html#insertItem">QMenuBar::insertItem</a>()
to insert a popup menu into a menu bar. Show a context menu either
asynchronously with <a href="#popup">popup</a>() or synchronously with <a href="#exec">exec</a>().
<p> Technically, a popup menu consists of a list of menu items. You add
items with <a href="qmenudata.html#insertItem">insertItem</a>().  An item is either a string, a pixmap or a
custom item that provides its own drawing function (see
<a href="qcustommenuitem.html">QCustomMenuItem</a>). In addition, items can have an optional icon drawn
on the very left side and an accelerator key such as "Ctrl+X".  The
accelerator can also be changed at run-time by holding the left mouse
button over an item and pressing the new accelerator.
<p> There are three kinds of menu items: separators, menu items that perform
an action and menu items that show a submenu.  Separators are inserted
with <a href="qmenudata.html#insertSeparator">insertSeparator</a>(). For submenus, you pass a pointer to a
QPopupMenu in your call to insertItem().  All other items are
considered action items.
<p> When inserting action items you usually specify a receiver and a
slot. The receiver will be notifed whenever the item is
selected. In addition, QPopupMenu provides two signals, <a href="#activated">activated</a>()
and <a href="#highlighted">highlighted</a>(), which signal the identifier of the respective menu
item. It is sometimes practical to connect several items to one
slot. To distinguish between them, specify a slot that takes an
integer argument and use <a href="qmenudata.html#setItemParameter">setItemParameter</a>() to associate a unique
value with each item.
<p> You clear a popup menu with <a href="qmenudata.html#clear">clear</a>() and remove single items with
<a href="qmenudata.html#removeItem">removeItem</a>() or <a href="qmenudata.html#removeItemAt">removeItemAt</a>().
<p> A popup menu can display check marks for certain items when enabled
with <a href="#setCheckable">setCheckable</a>(TRUE). You check or uncheck items with
<a href="qmenudata.html#setItemChecked">setItemChecked</a>().
<p> Items are either enabled or disabled. You toggle their state with
<a href="qmenudata.html#setItemEnabled">setItemEnabled</a>().  Just before a popup menu becomes visible, it
emits the <a href="#aboutToShow">aboutToShow</a>() signal. You can use this signal to set the
correct enabled/disabled states of all menu items before the user
sees it. The corresponding <a href="#aboutToHide">aboutToHide</a>() signal is emitted when the
menu hides again.
<p> You can provide What's This? help for single menu items with
<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>(). See <a href="qwhatsthis.html">QWhatsThis</a> for general information about this
kind of lightweight <a href="helpsystem.html#online-help">online help</a>.
<p> For ultimate flexibility, you can also add entire widgets as items
into a popup menu (for example, a color selector).
<p> A QPopupMenu can also provide a tear-off menu. A tear-off menu is a
top-level window that contains a copy of the menu. This makes it
possible for the user to "tear off" frequently used menus and
position them in a convenient place on the screen. If you want that
functionality for a certain menu, insert a tear-off handle with
<a href="#insertTearOffHandle">insertTearOffHandle</a>(). If you want to include custom widgets in a
tear-off menu, you should connect to the popup menu's signal (using
<a href="qmenudata.html#connectItem">connectItem</a>() and the item ID that insertTearOffHandle() returns),
and add the custom widgets you want to include. When using tear-off
menus, bear in mind that the concept isn't typically used on
Microsoft Windows so users may not be familiar with it. Consider
using a <a href="qtoolbar.html">QToolBar</a> instead.
<p> menu/menu.cpp is a typical example of <a href="qmenubar.html">QMenuBar</a> and QPopupMenu use.
<p> 
<p> <img src=qpopmenu-m.png> <img src=qpopmenu-w.png>
<p> <p>See also <a href="qmenubar.html">QMenuBar</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Menu, Drop-Down and
 Pop-Up</a>, <a href="application.html">Main Window and Related Classes</a> and <a href="basic.html">Basic Widgets</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QPopupMenu"></a>QPopupMenu::QPopupMenu ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs a popup menu with a the <em>parent</em> called <em>name</em>.
<p> Although a popup menu is always a top-level widget, if a parent is
passed the popup menu will be deleted when that parent is destroyed
(as with any other <a href="qobject.html">QObject</a>).
<p> 
<h3 class=fn><a name="~QPopupMenu"></a>QPopupMenu::~QPopupMenu ()
</h3>
Destroys the popup menu.

<h3 class=fn>void <a name="aboutToHide"></a>QPopupMenu::aboutToHide ()<tt> [signal]</tt>
</h3> 
<p> This signal is emitted just before the popup menu is hidden after it
has been displayed.
<p> <b>Warning:</b> Do not open a widget in a slot connected to this signal.
<p> <p>See also <a href="#aboutToShow">aboutToShow</a>(), <a href="qmenudata.html#setItemEnabled">setItemEnabled</a>(), <a href="qmenudata.html#setItemChecked">setItemChecked</a>(), <a href="qmenudata.html#insertItem">insertItem</a>() and <a href="qmenudata.html#removeItem">removeItem</a>().

<h3 class=fn>void <a name="aboutToShow"></a>QPopupMenu::aboutToShow ()<tt> [signal]</tt>
</h3> 
<p> This signal is emitted just before the popup menu is displayed.  You
can connect it to any slot that sets up the menu contents (e.g. to
ensure that the right items are enabled).
<p> <p>See also <a href="#aboutToHide">aboutToHide</a>(), <a href="qmenudata.html#setItemEnabled">setItemEnabled</a>(), <a href="qmenudata.html#setItemChecked">setItemChecked</a>(), <a href="qmenudata.html#insertItem">insertItem</a>() and <a href="qmenudata.html#removeItem">removeItem</a>().

<p>Example: <a href="mdi-example.html#x1166">mdi/application.cpp</a>.
<h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QMenuData::accel ( int&nbsp;id ) const
</h3>
Returns the accelerator key that has been defined for the menu item <em>id</em>,
or 0 if it has no accelerator key.
<p> <p>See also <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>.

<h3 class=fn>void <a name="activated"></a>QPopupMenu::activated ( int&nbsp;id )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when a menu item is selected; <em>id</em> is the id
of the selected item.
<p> Normally, you connect each menu item to a single slot using
<a href="qmenudata.html#insertItem">QMenuData::insertItem</a>(), but sometimes you will want to connect
several items to a single slot (most often if the user selects from
an array).  This signal is useful in such cases.
<p> <p>See also <a href="#highlighted">highlighted</a>() and <a href="qmenudata.html#insertItem">QMenuData::insertItem</a>().

<p>Examples: <a href="grapher-nsplugin-example.html#x2619">grapher/grapher.cpp</a>, <a href="helpviewer-example.html#x1411">helpviewer/helpwindow.cpp</a>, <a href="qdir-example.html#x793">qdir/qdir.cpp</a>, <a href="qwerty-example.html#x648">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x495">scrollview/scrollview.cpp</a> and <a href="showimg-example.html#x441">showimg/showimg.cpp</a>.
<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 )
</h3>
Changes the text of the menu item <em>id</em> to <em>text</em>. If the item has
an icon, the icon remains unchanged.
<p>See also <a href="qmenudata.html#text">text</a>().

<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 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Changes the pixmap of the menu item <em>id</em> to the pixmap
<em>pixmap</em>. If the item has an icon, the icon is unchanged.
<p>See also <a href="qmenudata.html#pixmap">pixmap</a>().

<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 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Changes the iconset and text of the menu item <em>id</em>
to the <em>icon</em> and <em>text</em> respectively.
<p>See also <a href="qmenudata.html#pixmap">pixmap</a>().

<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 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Changes the iconset and pixmap of the menu item <em>id</em>
to <em>icon</em> and <em>pixmap</em> respectively.
<p>See also <a href="qmenudata.html#pixmap">pixmap</a>().

<h3 class=fn>void <a name="clear"></a>QMenuData::clear ()
</h3>
Removes all menu items.
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>() and <a href="qmenudata.html#removeItemAt">removeItemAt</a>().

<p>Examples: <a href="mdi-example.html#x1147">mdi/application.cpp</a> and <a href="qwerty-example.html#x632">qwerty/qwerty.cpp</a>.
<h3 class=fn>int <a name="columns"></a>QPopupMenu::columns () const<tt> [protected]</tt>
</h3>
If a popup menu does not fit on the screen it lays itself out in
multiple columns until it does fit.
<p> This functions returns the number of columns necessary.
<p> <p>See also <a href="qwidget.html#sizeHint-prop">sizeHint</a>.

<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 )
</h3>
Connects the menu item with identifier <em>id</em> to <em>receiver</em>'s
<em>member</em> slot or signal.
<p> The receiver's slot/signal is activated when the menu item is activated.
<p> <p>See also <a href="qmenudata.html#disconnectItem">disconnectItem</a>() and <a href="qmenudata.html#setItemParameter">setItemParameter</a>().

<p>Example: <a href="menu-example.html#x1122">menu/menu.cpp</a>.
<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 )
</h3>
Disconnects the <em>receiver</em>'s <em>member</em> from the menu item with
identifier <em>id</em>.
<p> All connections are removed when the menu data object is destroyed.
<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>() and <a href="qmenudata.html#setItemParameter">setItemParameter</a>().

<h3 class=fn>void <a name="drawContents"></a>QPopupMenu::drawContents ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p )<tt> [virtual protected]</tt>
</h3>
Draws all menu items using painter <em>p</em>.

<p>Reimplemented from <a href="qframe.html#drawContents">QFrame</a>.
<h3 class=fn>void <a name="drawItem"></a>QPopupMenu::drawItem ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;tab_, QMenuItem&nbsp;*&nbsp;mi, bool&nbsp;act, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )<tt> [protected]</tt>
</h3>
Draws menu item <em>mi</em> in the area <em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>,
using painter <em>p</em>.  The item is drawn active if <em>act</em> is TRUE or
drawn inactive if <em>act</em> is FALSE. The rightmost <em>tab_</em> pixels are
used for accelerator text.
<p> <p>See also <a href="qstyle.html#drawControl">QStyle::drawControl</a>().

<h3 class=fn>int <a name="exec"></a>QPopupMenu::exec ()
</h3>  Executes this popup synchronously.
<p> This is equivalent to <tt>exec(mapToGlobal(QPoint(0,0)))</tt>.
In most situations you'll want to specify the position yourself,
for example at the current mouse position:
<pre>
      <a href="#exec">exec</a>(QCursor::<a href="qcursor.html#pos">pos</a>());
  </pre>
 
or aligned to a widget:
<pre>
      <a href="#exec">exec</a>(somewidget.mapToGlobal(QPoint(0,0)));
  </pre>
 

<p>Examples: <a href="fileiconview-example.html#x1578">fileiconview/qfileiconview.cpp</a> and <a href="scribble-example.html#x538">scribble/scribble.cpp</a>.
<h3 class=fn>int <a name="exec-2"></a>QPopupMenu::exec ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos, int&nbsp;indexAtPoint = 0 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Executes this popup synchronously.
<p> Opens the popup menu so that the item number <em>indexAtPoint</em> will be
at the specified <em>global</em> position <em>pos</em>.  To translate a widget's
local coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().
<p> The return code is the id of the selected item in either the popup
menu or one of its submenus, or -1 if no item is selected (normally
because the user presses Escape).
<p> Note that all signals are emitted as usual.  If you connect a menu
item to a slot and call the menu's <a href="#exec">exec</a>(), you get the result both
via the signal-slot connection and in the return value of exec().
<p> Common usage is to position the popup at the current
mouse position:
<pre>
      <a href="#exec">exec</a>(QCursor::<a href="qcursor.html#pos">pos</a>());
  </pre>
 
or aligned to a widget:
<pre>
      <a href="#exec">exec</a>(somewidget.mapToGlobal(QPoint(0,0)));
  </pre>
 
<p> When positioning a popup with exec() or <a href="#popup">popup</a>(), bear in mind that
you cannot rely on the popup menu's current <a href="qwidget.html#size">size</a>(). For performance
reasons, the popup adapts its size only when necessary. So in many
cases, the size before and after the show is different. Instead, use
<a href="qwidget.html#sizeHint">sizeHint</a>(). It calculates the proper size depending on the menu's
current contents.
<p> <p>See also <a href="#popup">popup</a>() and <a href="qwidget.html#sizeHint-prop">sizeHint</a>.

<h3 class=fn>void <a name="highlighted"></a>QPopupMenu::highlighted ( int&nbsp;id )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when a menu item is highlighted; <em>id</em> is the
id of the highlighted item.
<p> Normally, you connect each menu item to a single slot using
<a href="qmenudata.html#insertItem">QMenuData::insertItem</a>(), but sometimes you will want to connect
several items to a single slot (most often if the user selects from
an array).  This signal is useful in such cases.
<p> <p>See also <a href="#activated">activated</a>() and <a href="qmenudata.html#insertItem">QMenuData::insertItem</a>().

<h3 class=fn><a href="qiconset.html">QIconSet</a>&nbsp;* <a name="iconSet"></a>QMenuData::iconSet ( int&nbsp;id ) const
</h3>
Returns the icon set that has been set for menu item <em>id</em>, or 0 if no icon
set has been set.
<p>See also <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#text">text</a>() and <a href="qmenudata.html#pixmap">pixmap</a>().

<h3 class=fn>int <a name="idAt"></a>QPopupMenu::idAt ( int&nbsp;index ) const
</h3>
<p> Returns the identifier of the menu item at position <em>index</em> in the internal
list, or -1 if <em>index</em> is out of range.
<p> <p>See also <a href="qmenudata.html#setId">QMenuData::setId</a>() and <a href="qmenudata.html#indexOf">QMenuData::indexOf</a>().

<p>Example: <a href="scrollview-example.html#x496">scrollview/scrollview.cpp</a>.
<h3 class=fn>int <a name="idAt-2"></a>QPopupMenu::idAt ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the id of the item at <em>pos</em>, or -1 if there is no item
there or if it is a separator item.

<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 )
</h3>
The family of <a href="qmenudata.html#insertItem">insertItem</a>() functions inserts menu items into a
popup menu or a menu bar.
<p> A menu item is usually either a text string or a pixmap, both with
an optional icon or keyboard accelerator. For special cases it is
also possible to insert custom items (see <a href="qcustommenuitem.html">QCustomMenuItem</a>) or even
widgets into popup menus.
<p> Some insertItem() members take a popup menu as an additional
argument. Use this to insert submenus to existing menus or pulldown
menus to a menu bar.
<p> The number of insert functions may look confusing, but they are actually
quite simple to use.
<p> This default version inserts a menu item with the text <em>text</em>, the
accelerator key <em>accel</em>, an id and an optional index and connects
it to the slot <em>member</em> in the object <em>receiver</em>.
<p> Example:
<pre>
    <a href="qmenubar.html">QMenuBar</a>   *mainMenu = new <a href="qmenubar.html">QMenuBar</a>;
    QPopupMenu *fileMenu = new QPopupMenu;
    fileMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "New",  myView, SLOT(newFile()), CTRL+Key_N );
    fileMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Open", myView, SLOT(open()),    CTRL+Key_O );
    mainMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "File", fileMenu );
  </pre>
 
<p> Not all insert functions take an object/slot parameter or an
accelerator key. Use <a href="qmenudata.html#connectItem">connectItem</a>() and <a href="qmenudata.html#setAccel">setAccel</a>() on these items.
<p> If you need to translate accelerators, use <a href="qobject.html#tr">tr</a>() with a string
description that use pass to the <a href="qkeysequence.html">QKeySequence</a> constructor:
<pre>
    fileMenu-&gt;insertItem( <a href="qobject.html#tr">tr</a>("Open"), myView, SLOT(open()),
                         <a href="qobject.html#tr">tr</a>("Ctrl+O") );
  </pre>
 
<p> In the example above, pressing Ctrl+N or selecting "Open" from the
menu activates the myView->open() function.
<p> Some insert functions take a <a href="qiconset.html">QIconSet</a> parameter to specify the
little menu item icon. Note that you can always pass a <a href="qpixmap.html">QPixmap</a>
object instead.
<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 Qt are not application-global,
instead they are bound to a certain top-level window. For example,
accelerators in QPopupMenu 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 <a href="qwidget.html#parentWidget">parentWidget</a>() chain. The menu
will then install its accelerator object on that top-level widget.
For all other cases use an independent <a href="qaccel.html">QAccel</a> object.
<p> <b>Warning:</b> Be careful when passing a literal 0 to <a href="qmenudata.html#insertItem">insertItem</a>() because
some C++ compilers choose the wrong overloaded function.
Cast the 0 to what you mean, e.g. <tt>(QObject*)0</tt>.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>.

<p>Examples: <a href="addressbook-example.html#x1960">addressbook/mainwindow.cpp</a>, <a href="canvas-example.html#x2536">canvas/canvas.cpp</a>, <a href="mdi-example.html#x1148">mdi/application.cpp</a>, <a href="menu-example.html#x1123">menu/menu.cpp</a>, <a href="qwerty-example.html#x633">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x487">scrollview/scrollview.cpp</a> and <a href="showimg-example.html#x427">showimg/showimg.cpp</a>.
<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 )
</h3>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>. 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 <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>.

<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 )
</h3>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>. 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 <a href="qpixmap.html#mask">QPixmap::mask</a>()).
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
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 <a href="qpixmap.html#mask">QPixmap::mask</a>()).
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>.

<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 )
</h3>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>.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
The icon will be displayed to the left of the text in the item.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
<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 <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
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 <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
<p> To look best when being highlighted as a menu item, the pixmap should
provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()).
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
The icon will be displayed to the left of the pixmap in the item.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
<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 <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>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>.
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 <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>() and <a href="qmenudata.html#connectItem">connectItem</a>().

<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 )
</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item that consists of the widget <em>widget</em> with
optional id <em>id</em>, and optional <em>index</em>.
<p> Ownership of <em>widget</em> is transferred to the popup menu or to the
menu bar.
<p> Theoretically, any widget can be inserted into a popup menu. In
practice, this only makes sense with certain widgets.
<p> If a widget is not focus-enabled (see <a href="qwidget.html#isFocusEnabled">QWidget::isFocusEnabled</a>()),
the menu treats it as a separator; this means that the item is not
selectable and will never get focus. In this way you can, for example,
simply insert a <a href="qlabel.html">QLabel</a> if you need a popup menu with a title.
<p> If the widget is focus-enabled it will get focus when the user
traverses the popup menu with the arrow keys. If the widget does not
accept ArrowUp and ArrowDown in its key event handler, the focus
will move back to the menu when the respective arrow key is hit
one more time. This works with a <a href="qlineedit.html">QLineEdit</a>, for example.  If the
widget accepts the arrow key itself, it must also provide the
possibility to put the focus back on the menu again by calling
<a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>(). Futhermore, if the
embedded widget closes the menu when the user made a selection, this
can be done safely by calling
<pre>
    if ( <a href="qwidget.html#isVisible">isVisible</a>() &amp;&amp;
         <a href="qwidget.html#parentWidget">parentWidget</a>() &amp;&amp;
         <a href="qwidget.html#parentWidget">parentWidget</a>()-&gt;inherits("QPopupMenu") )
        <a href="qwidget.html#parentWidget">parentWidget</a>()-&gt;close();
  </pre>
 
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>().

<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 )
</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a custom menu item <em>custom</em> with an <em>icon</em> and with
optional id <em>id</em>, and optional <em>index</em>.
<p> This only works with popup menus. It is not supported for menu bars.
Ownership of <em>custom</em> is transferred to the popup menu.
<p> If you want to connect a custom item to a certain slot, use <a href="qmenudata.html#connectItem">connectItem</a>().
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#removeItem">removeItem</a>() and <a href="qcustommenuitem.html">QCustomMenuItem</a>.

<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 )
</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a custom menu item <em>custom</em> with
optional id <em>id</em>, and optional <em>index</em>.
<p> This only works with popup menus. It is not supported for menu bars.
Ownership of <em>custom</em> is transferred to the popup menu.
<p> If you want to connect a custom item to a certain slot, use <a href="qmenudata.html#connectItem">connectItem</a>().
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#removeItem">removeItem</a>() and <a href="qcustommenuitem.html">QCustomMenuItem</a>.

<h3 class=fn>int <a name="insertSeparator"></a>QMenuData::insertSeparator ( int&nbsp;index = -1 )
</h3>
Inserts a separator at position <em>index</em>.
The separator becomes the last menu item if <em>index</em> is negative.
<p> In a popup menu a separator is rendered as a horizontal line.  In a
Motif menu bar a separator is spacing, so the rest of the items
(normally just "Help") are drawn right-justified.  In a Windows
menu bar separators are ignored (to comply with the Windows style
guidelines).

<p>Examples: <a href="addressbook-example.html#x1961">addressbook/mainwindow.cpp</a>, <a href="mdi-example.html#x1149">mdi/application.cpp</a>, <a href="menu-example.html#x1124">menu/menu.cpp</a>, <a href="progress-example.html#x839">progress/progress.cpp</a>, <a href="scrollview-example.html#x488">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x428">showimg/showimg.cpp</a> and <a href="sound-example.html#x2482">sound/sound.cpp</a>.
<h3 class=fn>int <a name="insertTearOffHandle"></a>QPopupMenu::insertTearOffHandle ( int&nbsp;id = -1, int&nbsp;index = -1 )
</h3>
Inserts a tear-off handle into the menu. A tear-off handle is a
special menu item that creates a copy of the menu when the menu is
selected. This "torn-off" copy lives in a separate window. It
contains the same menu items as the original menu, with the exception
of the tear-off handle.
<p> The handle item is assigned the identifier <em>id</em> or an automatically
generated identifier if <em>id</em> is < 0. The generated identifiers
(negative integers) are guaranteed to be unique within the entire
application.
<p> The <em>index</em> specifies the position in the menu.  The tear-off
handle is appended at the end of the list if <em>index</em> is negative.

<p>Example: <a href="menu-example.html#x1132">menu/menu.cpp</a>.
<h3 class=fn>bool <a name="isCheckable"></a>QPopupMenu::isCheckable () const
</h3><p>Returns TRUE if the display of check marks on menu items is enabled; otherwise returns FALSE.
See the <a href="qpopupmenu.html#checkable-prop">"checkable"</a> property for details.
<h3 class=fn>bool <a name="isItemChecked"></a>QMenuData::isItemChecked ( int&nbsp;id ) const
</h3>
Returns TRUE if the menu item with the id <em>id</em> has been checked;
otherwise returns FALSE.
<p> <p>See also <a href="qmenudata.html#setItemChecked">setItemChecked</a>().

<p>Examples: <a href="canvas-example.html#x2538">canvas/canvas.cpp</a>, <a href="progress-example.html#x840">progress/progress.cpp</a> and <a href="showimg-example.html#x429">showimg/showimg.cpp</a>.
<h3 class=fn>bool <a name="isItemEnabled"></a>QMenuData::isItemEnabled ( int&nbsp;id ) const
</h3>
Returns TRUE if the item with identifier <em>id</em> is enabled; otherwise
returns FALSE
<p>See also <a href="qmenudata.html#setItemEnabled">setItemEnabled</a>().

<h3 class=fn>int <a name="itemHeight"></a>QPopupMenu::itemHeight ( int&nbsp;row ) const<tt> [protected]</tt>
</h3>
Calculates the height in pixels of the item in row <em>row</em>.

<h3 class=fn>int <a name="itemHeight-2"></a>QPopupMenu::itemHeight ( QMenuItem&nbsp;*&nbsp;mi ) const<tt> [protected]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Calculates the height in pixels of the menu item <em>mi</em>.

<h3 class=fn>int <a name="itemParameter"></a>QMenuData::itemParameter ( int&nbsp;id ) const
</h3>
Returns the parameter of the activation signal of item <em>id</em>.
<p> If no parameter has been specified for this item with
<a href="qmenudata.html#setItemParameter">setItemParameter</a>(), the value defaults to <em>id</em>.
<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#disconnectItem">disconnectItem</a>() and <a href="qmenudata.html#setItemParameter">setItemParameter</a>().

<h3 class=fn><a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="pixmap"></a>QMenuData::pixmap ( int&nbsp;id ) const
</h3>
Returns the pixmap that has been set for menu item <em>id</em>, or 0 if no pixmap
has been set.
<p> <p>See also <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#text">text</a>() and <a href="qmenudata.html#iconSet">iconSet</a>().

<h3 class=fn>void <a name="popup"></a>QPopupMenu::popup ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos, int&nbsp;indexAtPoint = 0 )
</h3>
Displays the popup menu so that the item number <em>indexAtPoint</em> will be
at the specified <em>global</em> position <em>pos</em>.  To translate a widget's
local coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().
<p> When positioning a popup with <a href="#exec">exec</a>() or <a href="#popup">popup</a>(), bear in mind that
you cannot rely on the popup menu's current <a href="qwidget.html#size">size</a>(). For performance
reasons, the popup adapts its size only when necessary, so in many
cases, the size before and after the show is different. Instead, use
<a href="qwidget.html#sizeHint">sizeHint</a>(). It calculates the proper size depending on the menu's
current contents.
<p> 
<p>Examples: <a href="listviews-example.html#x1228">listviews/listviews.cpp</a> and <a href="qtimage-nsplugin-example.html#x2448">qtimage/qtimage.cpp</a>.
<h3 class=fn>void <a name="removeItem"></a>QMenuData::removeItem ( int&nbsp;id )
</h3>

Removes the menu item that has the identifier <em>id</em>.
<p>See also <a href="qmenudata.html#removeItemAt">removeItemAt</a>() and <a href="qmenudata.html#clear">clear</a>().

<h3 class=fn>void <a name="removeItemAt"></a>QMenuData::removeItemAt ( int&nbsp;index )
</h3>
Removes the menu item at position <em>index</em>.
<p>See also <a href="qmenudata.html#removeItem">removeItem</a>() and <a href="qmenudata.html#clear">clear</a>().

<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 )
</h3>
Sets the accelerator key for the menu item <em>id</em> to <em>key</em>.
<p> An accelerator key consists of a key code and a combination of the modifiers
<a href="qt.html#Modifier-enum">SHIFT</a>, <a href="qt.html#Modifier-enum">CTRL</a>, <a href="qt.html#Modifier-enum">ALT</a> or <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a> (OR'ed or added).
The header file qnamespace.h contains a list of key codes.
<p> Defining an accelerator key produces a text that is added to the
menu item; for instance, <a href="qt.html#Modifier-enum">CTRL</a> + <a href="qt.html#Key-enum">Key_O</a> produces "Ctrl+O".  The
text is formatted differently for different platforms.
<p> Note that keyboard accelerators in Qt are not application-global,
instead they are bound to a certain top-level window. For example,
accelerators in QPopupMenu 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 <a href="qwidget.html#parentWidget">parentWidget</a>() chain. The menu
will then install its accelerator object on that top-level widget.
For all other cases use an independent <a href="qaccel.html">QAccel</a> object.
<p> Example:
<pre>
    <a href="qmenubar.html">QMenuBar</a> *mainMenu = new <a href="qmenubar.html">QMenuBar</a>;
    QPopupMenu *fileMenu = new QPopupMenu;       // file sub menu
    fileMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Open Document", 67 ); // add "Open" item
    fileMenu-&gt;<a href="qmenudata.html#setAccel">setAccel</a>( CTRL + Key_O, 67 );      // Control and O to open
    fileMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Quit", 69 );          // add "Quit" item
    fileMenu-&gt;<a href="qmenudata.html#setAccel">setAccel</a>( CTRL + ALT + Key_Delete, 69 );
    mainMenu-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "File", fileMenu );    // add the file menu
  </pre>
 
<p> If you need to translate accelerators, use <a href="qobject.html#tr">tr</a>() with a string:
<pre>
    fileMenu-&gt;setAccel( <a href="qobject.html#tr">tr</a>("Ctrl+O"), 67 );
  </pre>
 
<p> You can also specify the accelerator in the <a href="qmenudata.html#insertItem">insertItem</a>() function.
You may prefer to use <a href="qaction.html">QAction</a> to associate accelerators with menu
items.
<p> <p>See also <a href="qmenudata.html#accel">accel</a>(), <a href="qmenudata.html#insertItem">insertItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qaction.html">QAction</a>.

<p>Example: <a href="menu-example.html#x1125">menu/menu.cpp</a>.
<h3 class=fn>void <a name="setActiveItem"></a>QPopupMenu::setActiveItem ( int&nbsp;i )<tt> [virtual]</tt>
</h3>  Sets the currently active item to <em>i</em> and repaints as necessary.

<h3 class=fn>void <a name="setCheckable"></a>QPopupMenu::setCheckable ( bool )<tt> [virtual]</tt>
</h3><p>Sets whether the display of check marks on menu items is enabled.
See the <a href="qpopupmenu.html#checkable-prop">"checkable"</a> property for details.
<h3 class=fn>void <a name="setItemChecked"></a>QMenuData::setItemChecked ( int&nbsp;id, bool&nbsp;check )
</h3>
If <em>check</em> is TRUE, checks the menu item with id <em>id</em>; otherwise
unchecks the menu item with id <em>id</em>.
Calls <a href="#setCheckable">QPopupMenu::setCheckable</a>( TRUE ) if necessary.
<p> <p>See also <a href="qmenudata.html#isItemChecked">isItemChecked</a>().

<p>Examples: <a href="canvas-example.html#x2539">canvas/canvas.cpp</a>, <a href="grapher-nsplugin-example.html#x2601">grapher/grapher.cpp</a>, <a href="mdi-example.html#x1150">mdi/application.cpp</a>, <a href="menu-example.html#x1126">menu/menu.cpp</a>, <a href="progress-example.html#x841">progress/progress.cpp</a>, <a href="scrollview-example.html#x489">scrollview/scrollview.cpp</a> and <a href="showimg-example.html#x430">showimg/showimg.cpp</a>.
<h3 class=fn>void <a name="setItemEnabled"></a>QMenuData::setItemEnabled ( int&nbsp;id, bool&nbsp;enable )
</h3>
If <em>enable</em> is TRUE, enables the menu item with identifier <em>id</em>;
otherwise disables the menu item with identifier <em>id</em>.
<p>See also <a href="qmenudata.html#isItemEnabled">isItemEnabled</a>().

<p>Examples: <a href="mdi-example.html#x1151">mdi/application.cpp</a>, <a href="menu-example.html#x1127">menu/menu.cpp</a>, <a href="progress-example.html#x842">progress/progress.cpp</a> and <a href="showimg-example.html#x431">showimg/showimg.cpp</a>.
<h3 class=fn>bool <a name="setItemParameter"></a>QMenuData::setItemParameter ( int&nbsp;id, int&nbsp;param )
</h3>
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 <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#disconnectItem">disconnectItem</a>() and <a href="qmenudata.html#itemParameter">itemParameter</a>().

<p>Example: <a href="mdi-example.html#x1152">mdi/application.cpp</a>.
<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 )
</h3>
Sets <em>text</em> as What's This help for the menu item with identifier <em>id</em>.
<p> <p>See also <a href="qmenudata.html#whatsThis">whatsThis</a>().

<p>Examples: <a href="simple-application-example.html#x1922">application/application.cpp</a> and <a href="mdi-example.html#x1153">mdi/application.cpp</a>.
<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QMenuData::text ( int&nbsp;id ) const
</h3>
Returns the text that has been set for menu item <em>id</em>, or a
<a href="qstring.html#operator!">null string</a>
if no text has been set.
<p> <p>See also <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#pixmap">pixmap</a>() and <a href="qmenudata.html#iconSet">iconSet</a>().

<p>Examples: <a href="qdir-example.html#x789">qdir/qdir.cpp</a> and <a href="showimg-example.html#x432">showimg/showimg.cpp</a>.
<h3 class=fn>void <a name="updateItem"></a>QPopupMenu::updateItem ( int&nbsp;id )<tt> [virtual]</tt>
</h3>
Updates the item with identity <em>id</em>.

<p>Reimplemented from <a href="qmenudata.html#updateItem">QMenuData</a>.
<h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QMenuData::whatsThis ( int&nbsp;id ) const
</h3>
Returns 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.
<p> <p>See also <a href="qmenudata.html#setWhatsThis">setWhatsThis</a>().

<hr><h2>Property Documentation</h2>
<h3 class=fn>bool <a name="checkable-prop"></a>checkable</h3>
<p>This property holds whether the display of check marks on menu items is enabled.
<p>When TRUE, the display of check marks on menu items is enabled.
Checking is always enabled when in Windows-style.
<p> <p>See also <a href="qmenudata.html#setItemChecked">QMenuData::setItemChecked</a>().

<p>Set this property's value with <a href="#setCheckable">setCheckable</a>() and get this property's value with <a href="#isCheckable">isCheckable</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 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 &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>