Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 4494

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qmenu.cpp -->
<head>
  <title>Qt 4.6: QMenu Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QMenu"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QMenu Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span>
</h1>
<p>The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus. <a href="#details">More...</a></p>
<pre> #include &lt;QMenu&gt;</pre><p>Inherits <a href="qwidget.html">QWidget</a>.</p>
<p>Inherited by <a href="q3popupmenu.html" class="compat">Q3PopupMenu</a>.</p>
<ul>
<li><a href="qmenu-members.html">List of all members, including inherited members</a></li>
<li><a href="qmenu-qt3.html">Qt 3 support members</a></li>
</ul>
<hr />
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li><div class="fn"><b><a href="qmenu.html#icon-prop">icon</a></b> : QIcon</div></li>
<li><div class="fn"><b><a href="qmenu.html#separatorsCollapsible-prop">separatorsCollapsible</a></b> : bool</div></li>
<li><div class="fn"><b><a href="qmenu.html#tearOffEnabled-prop">tearOffEnabled</a></b> : bool</div></li>
<li><div class="fn"><b><a href="qmenu.html#title-prop">title</a></b> : QString</div></li>
</ul>
<ul>
<li><div bar="2" class="fn"></div>58 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div bar="2" class="fn"></div>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#QMenu">QMenu</a></b> ( QWidget * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#QMenu-2">QMenu</a></b> ( const QString &amp; <i>title</i>, QWidget * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#dtor.QMenu">~QMenu</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#actionAt">actionAt</a></b> ( const QPoint &amp; <i>pt</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QRect </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#actionGeometry">actionGeometry</a></b> ( QAction * <i>act</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#activeAction">activeAction</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addAction">addAction</a></b> ( const QString &amp; <i>text</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addAction-2">addAction</a></b> ( const QIcon &amp; <i>icon</i>, const QString &amp; <i>text</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addAction-3">addAction</a></b> ( const QString &amp; <i>text</i>, const QObject * <i>receiver</i>, const char * <i>member</i>, const QKeySequence &amp; <i>shortcut</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addAction-4">addAction</a></b> ( const QIcon &amp; <i>icon</i>, const QString &amp; <i>text</i>, const QObject * <i>receiver</i>, const char * <i>member</i>, const QKeySequence &amp; <i>shortcut</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addAction-5">addAction</a></b> ( QAction * <i>action</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addMenu">addMenu</a></b> ( QMenu * <i>menu</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QMenu * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addMenu-2">addMenu</a></b> ( const QString &amp; <i>title</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QMenu * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addMenu-3">addMenu</a></b> ( const QIcon &amp; <i>icon</i>, const QString &amp; <i>title</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#addSeparator">addSeparator</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#clear">clear</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#defaultAction">defaultAction</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#exec">exec</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#exec-2">exec</a></b> ( const QPoint &amp; <i>p</i>, QAction * <i>action</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QIcon </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#icon-prop">icon</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#insertMenu">insertMenu</a></b> ( QAction * <i>before</i>, QMenu * <i>menu</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#insertSeparator">insertSeparator</a></b> ( QAction * <i>before</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#isEmpty">isEmpty</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#menuAction">menuAction</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#popup">popup</a></b> ( const QPoint &amp; <i>p</i>, QAction * <i>atAction</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#separatorsCollapsible-prop">separatorsCollapsible</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#setActiveAction">setActiveAction</a></b> ( QAction * <i>act</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#setDefaultAction">setDefaultAction</a></b> ( QAction * <i>act</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#icon-prop">setIcon</a></b> ( const QIcon &amp; <i>icon</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#separatorsCollapsible-prop">setSeparatorsCollapsible</a></b> ( bool <i>collapse</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#tearOffEnabled-prop">setTearOffEnabled</a></b> ( bool )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#title-prop">setTitle</a></b> ( const QString &amp; <i>title</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#title-prop">title</a></b> () const</td></tr>
</table>
<hr />
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual QSize </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#sizeHint">sizeHint</a></b> () const</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>217 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div bar="2" class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div bar="2" class="fn"></div>13 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<hr />
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#aboutToHide">aboutToHide</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#aboutToShow">aboutToShow</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#hovered">hovered</a></b> ( QAction * <i>action</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#triggered">triggered</a></b> ( QAction * <i>action</i> )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div bar="2" class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<hr />
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#exec-3">exec</a></b> ( QList&lt;QAction *&gt; <i>actions</i>, const QPoint &amp; <i>pos</i>, QAction * <i>at</i>, QWidget * <i>parent</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAction * </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#exec-4">exec</a></b> ( QList&lt;QAction *&gt; <i>actions</i>, const QPoint &amp; <i>pos</i>, QAction * <i>at</i> = 0 )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div bar="2" class="fn"></div>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<hr />
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#columnCount">columnCount</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#initStyleOption">initStyleOption</a></b> ( QStyleOptionMenuItem * <i>option</i>, const QAction * <i>action</i> ) const</td></tr>
</table>
<hr />
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#actionEvent">actionEvent</a></b> ( QActionEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#changeEvent">changeEvent</a></b> ( QEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#enterEvent">enterEvent</a></b> ( QEvent * )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#event">event</a></b> ( QEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#focusNextPrevChild">focusNextPrevChild</a></b> ( bool <i>next</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#hideEvent">hideEvent</a></b> ( QHideEvent * )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#leaveEvent">leaveEvent</a></b> ( QEvent * )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#mouseMoveEvent">mouseMoveEvent</a></b> ( QMouseEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#mousePressEvent">mousePressEvent</a></b> ( QMouseEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#mouseReleaseEvent">mouseReleaseEvent</a></b> ( QMouseEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#paintEvent">paintEvent</a></b> ( QPaintEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#timerEvent">timerEvent</a></b> ( QTimerEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qmenu.html#wheelEvent">wheelEvent</a></b> ( QWheelEvent * <i>e</i> )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div bar="2" class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div bar="2" class="fn"></div>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"></div>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"></div>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.</p>
<p>A menu widget is a selection menu. It can be either a pull-down menu in a menu bar or a standalone context menu. Pull-down menus are shown by the menu bar when the user clicks on the respective item or presses the specified shortcut key. Use <a href="qmenubar.html#addMenu">QMenuBar::addMenu</a>() to insert a menu into a menu bar. Context menus are usually invoked by some special keyboard key or by right-clicking. They can be executed either asynchronously with <a href="qmenu.html#popup">popup</a>() or synchronously with <a href="qmenu.html#exec">exec</a>(). Menus can also be invoked in response to button presses; these are just like context menus except for how they are invoked.</p>
    <table align="center" cellpadding="0">
    <tr>
        <td>
            <p><img src="images/plastique-menu.png" /></p>
        </td>
        <td>
            <p><img src="images/windowsxp-menu.png" /></p>
        </td>
        <td>
            <p><img src="images/macintosh-menu.png" /></p>
        </td>

    </tr>
    <tr>
        <td colspan="3">
           <p>A menu shown in <a href="gallery-plastique.html">Plastique widget style</a>, <a href="gallery-windowsxp.html">Windows XP widget style</a>, and <a href="gallery-macintosh.html">Macintosh widget style</a>.</p>
        </td>
    </tr>
    </table>
    <a name="actions"></a>
<h3>Actions</h3>
<p>A menu consists of a list of action items. Actions are added with the <a href="qmenu.html#addAction">addAction</a>(), <a href="qwidget.html#addActions">addActions</a>() and <a href="qwidget.html#insertAction">insertAction</a>() functions. An action is represented vertically and rendered by <a href="qstyle.html">QStyle</a>. In addition, actions can have a text label, an optional icon drawn on the very left side, and shortcut key sequence such as &quot;Ctrl+X&quot;.</p>
<p>The existing actions held by a menu can be found with <a href="qwidget.html#actions">actions</a>().</p>
<p>There are four kinds of action items: separators, actions that show a submenu, widgets, and actions that perform an action. Separators are inserted with <a href="qmenu.html#addSeparator">addSeparator</a>(), submenus with <a href="qmenu.html#addMenu">addMenu</a>(), and all other items are considered action items.</p>
<p>When inserting action items you usually specify a receiver and a slot. The receiver will be notifed whenever the item is <a href="qaction.html#triggered">triggered()</a>. In addition, QMenu provides two signals, <a href="qmenu-qt3.html#activated" class="compat">activated</a>() and <a href="qmenu-qt3.html#highlighted" class="compat">highlighted</a>(), which signal the <a href="qaction.html">QAction</a> that was triggered from the menu.</p>
<p>You clear a menu with <a href="qmenu.html#clear">clear</a>() and remove individual action items with <a href="qwidget.html#removeAction">removeAction</a>().</p>
<p>A QMenu 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 &quot;tear off&quot; frequently used menus and position them in a convenient place on the screen. If you want this functionality for a particular menu, insert a tear-off handle with <a href="qmenu.html#tearOffEnabled-prop">setTearOffEnabled</a>(). When using tear-off menus, bear in mind that the concept isn't typically used on Microsoft Windows so some users may not be familiar with it. Consider using a <a href="qtoolbar.html">QToolBar</a> instead.</p>
<p>Widgets can be inserted into menus with the <a href="qwidgetaction.html">QWidgetAction</a> class. Instances of this class are used to hold widgets, and are inserted into menus with the <a href="qmenu.html#addAction">addAction</a>() overload that takes a <a href="qaction.html">QAction</a>.</p>
<p>Conversely, actions can be added to widgets with the <a href="qmenu.html#addAction">addAction</a>(), <a href="qwidget.html#addActions">addActions</a>() and <a href="qwidget.html#insertAction">insertAction</a>() functions.</p>
<a name="qmenu-on-qt-for-windows-ce"></a>
<h3>QMenu on Qt for Windows CE</h3>
<p>If a menu is integrated into the native menubar on Windows Mobile we do not support the signals: aboutToHide (), aboutToShow () and hovered (). It is not possible to display an icon in a native menu on Windows Mobile.</p>
<a name="qmenu-on-mac-os-x-with-qt-build-against-cocoa"></a>
<h3>QMenu on Mac OS X with Qt build against Cocoa</h3>
<p>QMenu can be inserted only once in a menu/menubar. Subsequent insertions will have no effect or will result in a disabled menu item.</p>
<p>See the <a href="mainwindows-menus.html">Menus</a> example for an example of how to use <a href="qmenubar.html">QMenuBar</a> and QMenu in your application.</p>
<p><b>Important inherited functions:</b> <a href="qmenu.html#addAction">addAction</a>(), <a href="qwidget.html#removeAction">removeAction</a>(), <a href="qmenu.html#clear">clear</a>(), <a href="qmenu.html#addSeparator">addSeparator</a>(), and <a href="qmenu.html#addMenu">addMenu</a>().</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="mainwindows-application.html">Application Example</a>, <a href="mainwindows-menus.html">Menus Example</a>, and <a href="mainwindows-recentfiles.html">Recent Files Example</a>.</p>
<hr />
<h2>Property Documentation</h2>
<a name="//apple_ref/cpp/instm/QMenu/icon"></a>
<a name="//apple_ref/cpp/instm/QMenu/setIcon"></a>
<h3 class="fn"><a name="icon-prop"></a>icon : <a href="qicon.html">QIcon</a></h3>
<p>This property holds the icon of the menu.</p>
<p>This is equivalent to the <a href="qaction.html#icon-prop">QAction::icon</a> property of the <a href="qmenu.html#menuAction">menuAction</a>().</p>
<p>By default, if no icon is explicitly set, this property contains a null icon.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QIcon </td><td class="memItemRight" valign="bottom"><b>icon</b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setIcon</b> ( const QIcon &amp; <i>icon</i> )</td></tr>
</table>
<a name="//apple_ref/cpp/instm/QMenu/separatorsCollapsible"></a>
<a name="//apple_ref/cpp/instm/QMenu/setSeparatorsCollapsible"></a>
<h3 class="fn"><a name="separatorsCollapsible-prop"></a>separatorsCollapsible : bool</h3>
<p>This property holds whether consecutive separators should be collapsed.</p>
<p>This property specifies whether consecutive separators in the menu should be visually collapsed to a single one. Separators at the beginning or the end of the menu are also hidden.</p>
<p>By default, this property is true.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b>separatorsCollapsible</b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setSeparatorsCollapsible</b> ( bool <i>collapse</i> )</td></tr>
</table>
<a name="//apple_ref/cpp/instm/QMenu/isTearOffEnabled"></a>
<a name="//apple_ref/cpp/instm/QMenu/setTearOffEnabled"></a>
<h3 class="fn"><a name="tearOffEnabled-prop"></a>tearOffEnabled : bool</h3>
<p>This property holds whether the menu supports being torn off.</p>
<p>When true, the menu contains a special tear-off item (often shown as a dashed line at the top of the menu) that creates a copy of the menu when it is triggered.</p>
<p>This &quot;torn-off&quot; 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>
<p>By default, this property is false.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b>isTearOffEnabled</b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setTearOffEnabled</b> ( bool )</td></tr>
</table>
<a name="//apple_ref/cpp/instm/QMenu/title"></a>
<a name="//apple_ref/cpp/instm/QMenu/setTitle"></a>
<h3 class="fn"><a name="title-prop"></a>title : <a href="qstring.html">QString</a></h3>
<p>This property holds the title of the menu.</p>
<p>This is equivalent to the <a href="qaction.html#text-prop">QAction::text</a> property of the <a href="qmenu.html#menuAction">menuAction</a>().</p>
<p>By default, this property contains an empty string.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b>title</b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setTitle</b> ( const QString &amp; <i>title</i> )</td></tr>
</table>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QMenu/QMenu"></a>
<h3 class="fn"><a name="QMenu"></a>QMenu::QMenu ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a menu with parent <i>parent</i>.</p>
<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="QMenu-2"></a>QMenu::QMenu ( const <a href="qstring.html">QString</a> &amp; <i>title</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a menu with a <i>title</i> and a <i>parent</i>.</p>
<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>
<p>See also <a href="qmenu.html#title-prop">title</a>.</p>
<a name="//apple_ref/cpp/instm/QMenu/~QMenu"></a>
<h3 class="fn"><a name="dtor.QMenu"></a>QMenu::~QMenu ()</h3>
<p>Destroys the menu.</p>
<a name="//apple_ref/cpp/instm/QMenu/aboutToHide"></a>
<h3 class="fn"><a name="aboutToHide"></a>void QMenu::aboutToHide ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted just before the menu is hidden from the user.</p>
<p>This function was introduced in Qt 4.2.</p>
<p>See also <a href="qmenu.html#aboutToShow">aboutToShow</a>() and <a href="qwidget.html#hide">hide</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/aboutToShow"></a>
<h3 class="fn"><a name="aboutToShow"></a>void QMenu::aboutToShow ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted just before the menu is shown to the user.</p>
<p>See also <a href="qmenu.html#aboutToHide">aboutToHide</a>() and <a href="qwidget.html#show">show</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/actionAt"></a>
<h3 class="fn"><a name="actionAt"></a><a href="qaction.html">QAction</a> * QMenu::actionAt ( const <a href="qpoint.html">QPoint</a> &amp; <i>pt</i> ) const</h3>
<p>Returns the item at <i>pt</i>; returns 0 if there is no item there.</p>
<a name="//apple_ref/cpp/instm/QMenu/actionEvent"></a>
<h3 class="fn"><a name="actionEvent"></a>void QMenu::actionEvent ( <a href="qactionevent.html">QActionEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#actionEvent">QWidget::actionEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/actionGeometry"></a>
<h3 class="fn"><a name="actionGeometry"></a><a href="qrect.html">QRect</a> QMenu::actionGeometry ( <a href="qaction.html">QAction</a> * <i>act</i> ) const</h3>
<p>Returns the geometry of action <i>act</i>.</p>
<a name="//apple_ref/cpp/instm/QMenu/activeAction"></a>
<h3 class="fn"><a name="activeAction"></a><a href="qaction.html">QAction</a> * QMenu::activeAction () const</h3>
<p>Returns the currently highlighted action, or 0 if no action is currently highlighted.</p>
<p>See also <a href="qmenu.html#setActiveAction">setActiveAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/addAction"></a>
<h3 class="fn"><a name="addAction"></a><a href="qaction.html">QAction</a> * QMenu::addAction ( const <a href="qstring.html">QString</a> &amp; <i>text</i> )</h3>
<p>This is an overloaded function.</p>
<p>This convenience function creates a new action with <i>text</i>. The function adds the newly created action to the menu's list of actions, and returns it.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<h3 class="fn"><a name="addAction-2"></a><a href="qaction.html">QAction</a> * QMenu::addAction ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i> )</h3>
<p>This is an overloaded function.</p>
<p>This convenience function creates a new action with an <i>icon</i> and some <i>text</i>. The function adds the newly created action to the menu's list of actions, and returns it.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<h3 class="fn"><a name="addAction-3"></a><a href="qaction.html">QAction</a> * QMenu::addAction ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qobject.html">QObject</a> * <i>receiver</i>, const char * <i>member</i>, const <a href="qkeysequence.html">QKeySequence</a> &amp; <i>shortcut</i> = 0 )</h3>
<p>This is an overloaded function.</p>
<p>This convenience function creates a new action with the text <i>text</i> and an optional shortcut <i>shortcut</i>. The action's <a href="qaction.html#triggered">triggered()</a> signal is connected to the <i>receiver</i>'s <i>member</i> slot. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<h3 class="fn"><a name="addAction-4"></a><a href="qaction.html">QAction</a> * QMenu::addAction ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qobject.html">QObject</a> * <i>receiver</i>, const char * <i>member</i>, const <a href="qkeysequence.html">QKeySequence</a> &amp; <i>shortcut</i> = 0 )</h3>
<p>This is an overloaded function.</p>
<p>This convenience function creates a new action with an <i>icon</i> and some <i>text</i> and an optional shortcut <i>shortcut</i>. The action's <a href="qaction.html#triggered">triggered()</a> signal is connected to the <i>member</i> slot of the <i>receiver</i> object. The function adds the newly created action to the menu's list of actions, and returns it.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<h3 class="fn"><a name="addAction-5"></a>void QMenu::addAction ( <a href="qaction.html">QAction</a> * <i>action</i> )</h3>
<p>This is an overloaded function.</p>
<p>Appends the action <i>action</i> to the menu's list of actions.</p>
<p>See also <a href="qmenubar.html#addAction">QMenuBar::addAction</a>() and <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/addMenu"></a>
<h3 class="fn"><a name="addMenu"></a><a href="qaction.html">QAction</a> * QMenu::addMenu ( QMenu * <i>menu</i> )</h3>
<p>This convenience function adds <i>menu</i> as a submenu to this menu. It returns <i>menu</i>'s <a href="qmenu.html#menuAction">menuAction</a>(). This menu does not take ownership of <i>menu</i>.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
<h3 class="fn"><a name="addMenu-2"></a>QMenu * QMenu::addMenu ( const <a href="qstring.html">QString</a> &amp; <i>title</i> )</h3>
<p>Appends a new <a href="qmenu.html">QMenu</a> with <i>title</i> to the menu. The menu takes ownership of the menu. Returns the new menu.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
<h3 class="fn"><a name="addMenu-3"></a>QMenu * QMenu::addMenu ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i> )</h3>
<p>Appends a new <a href="qmenu.html">QMenu</a> with <i>icon</i> and <i>title</i> to the menu. The menu takes ownership of the menu. Returns the new menu.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/addSeparator"></a>
<h3 class="fn"><a name="addSeparator"></a><a href="qaction.html">QAction</a> * QMenu::addSeparator ()</h3>
<p>This convenience function creates a new separator action, i.e&#x2e; an action with <a href="qaction.html#isSeparator">QAction::isSeparator</a>() returning true, and adds the new action to this menu's list of actions. It returns the newly created action.</p>
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/changeEvent"></a>
<h3 class="fn"><a name="changeEvent"></a>void QMenu::changeEvent ( <a href="qevent.html">QEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget::changeEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/clear"></a>
<h3 class="fn"><a name="clear"></a>void QMenu::clear ()</h3>
<p>Removes all the menu's actions. Actions owned by the menu and not shown in any other widget are deleted.</p>
<p>See also <a href="qwidget.html#removeAction">removeAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/columnCount"></a>
<h3 class="fn"><a name="columnCount"></a>int QMenu::columnCount () const&nbsp;&nbsp;<tt> [protected]</tt></h3>
<p>If a menu does not fit on the screen it lays itself out so that it does fit. It is style dependent what layout means (for example, on Windows it will use multiple columns).</p>
<p>This functions returns the number of columns necessary.</p>
<a name="//apple_ref/cpp/instm/QMenu/defaultAction"></a>
<h3 class="fn"><a name="defaultAction"></a><a href="qaction.html">QAction</a> * QMenu::defaultAction () const</h3>
<p>Returns the current default action.</p>
<p>See also <a href="qmenu.html#setDefaultAction">setDefaultAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/enterEvent"></a>
<h3 class="fn"><a name="enterEvent"></a>void QMenu::enterEvent ( <a href="qevent.html">QEvent</a> * )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#enterEvent">QWidget::enterEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/event"></a>
<h3 class="fn"><a name="event"></a>bool QMenu::event ( <a href="qevent.html">QEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/exec"></a>
<h3 class="fn"><a name="exec"></a><a href="qaction.html">QAction</a> * QMenu::exec ()</h3>
<p>Executes this menu synchronously.</p>
<p>This is equivalent to <tt>exec(pos())</tt>.</p>
<p>This returns the triggered <a href="qaction.html">QAction</a> in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).</p>
<p>In most situations you'll want to specify the position yourself, for example, the current mouse position:</p>
<pre> exec(QCursor::pos());</pre>
<p>or aligned to a widget:</p>
<pre> exec(somewidget.mapToGlobal(QPoint(0,0)));</pre>
<p>or in reaction to a <a href="qmouseevent.html">QMouseEvent</a> *e:</p>
<pre> exec(e-&gt;globalPos());</pre>
<h3 class="fn"><a name="exec-2"></a><a href="qaction.html">QAction</a> * QMenu::exec ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i>, <a href="qaction.html">QAction</a> * <i>action</i> = 0 )</h3>
<p>This is an overloaded function.</p>
<p>Executes this menu synchronously.</p>
<p>Pops up the menu so that the action <i>action</i> will be at the specified <i>global</i> position <i>p</i>. To translate a widget's local coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<p>This returns the triggered <a href="qaction.html">QAction</a> in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).</p>
<p>Note that all signals are emitted as usual. If you connect a <a href="qaction.html">QAction</a> to a slot and call the menu's <a href="qmenu.html#exec">exec</a>(), you get the result both via the signal-slot connection and in the return value of <a href="qmenu.html#exec">exec</a>().</p>
<p>Common usage is to position the menu at the current mouse position:</p>
<pre> exec(QCursor::pos());</pre>
<p>or aligned to a widget:</p>
<pre> exec(somewidget.mapToGlobal(QPoint(0, 0)));</pre>
<p>or in reaction to a <a href="qmouseevent.html">QMouseEvent</a> *e:</p>
<pre> exec(e-&gt;globalPos());</pre>
<p>When positioning a menu with <a href="qmenu.html#exec">exec</a>() or <a href="qmenu.html#popup">popup</a>(), bear in mind that you cannot rely on the menu's current <a href="qwidget.html#size-prop">size</a>(). For performance reasons, the menu adapts its size only when necessary. So in many cases, the size before and after the show is different. Instead, use <a href="qmenu.html#sizeHint">sizeHint</a>() which calculates the proper size depending on the menu's current contents.</p>
<p>See also <a href="qmenu.html#popup">popup</a>() and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<h3 class="fn"><a name="exec-3"></a><a href="qaction.html">QAction</a> * QMenu::exec ( <a href="qlist.html">QList</a>&lt;<a href="qaction.html">QAction</a> *&gt; <i>actions</i>, const <a href="qpoint.html">QPoint</a> &amp; <i>pos</i>, <a href="qaction.html">QAction</a> * <i>at</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded function.</p>
<p>Executes a menu synchronously.</p>
<p>The menu's actions are specified by the list of <i>actions</i>. The menu will pop up so that the specified action, <i>at</i>, appears at global position <i>pos</i>. If <i>at</i> is not specified then the menu appears at position <i>pos</i>. <i>parent</i> is the menu's parent widget; specifying the parent will provide context when <i>pos</i> alone is not enough to decide where the menu should go (e.g&#x2e;, with multiple desktops or when the parent is embedded in <a href="qgraphicsview.html">QGraphicsView</a>).</p>
<p>The function returns the triggered <a href="qaction.html">QAction</a> in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).</p>
<p>This is equivalent to:</p>
<pre> QMenu menu;
 QAction *at = actions[0]; <span class="comment">// Assumes actions is not empty</span>
 foreach (QAction *a, actions)
     menu.addAction(a);
 menu.exec(pos, at);</pre>
<p>See also <a href="qmenu.html#popup">popup</a>() and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<h3 class="fn"><a name="exec-4"></a><a href="qaction.html">QAction</a> * QMenu::exec ( <a href="qlist.html">QList</a>&lt;<a href="qaction.html">QAction</a> *&gt; <i>actions</i>, const <a href="qpoint.html">QPoint</a> &amp; <i>pos</i>, <a href="qaction.html">QAction</a> * <i>at</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded function.</p>
<p>Executes a menu synchronously.</p>
<p>The menu's actions are specified by the list of <i>actions</i>. The menu will pop up so that the specified action, <i>at</i>, appears at global position <i>pos</i>. If <i>at</i> is not specified then the menu appears at position <i>pos</i>.</p>
<p>The function returns the triggered <a href="qaction.html">QAction</a> in either the popup menu or one of its submenus, or 0 if no item was triggered (normally because the user pressed Esc).</p>
<p>This is equivalent to:</p>
<pre> QMenu menu;
 QAction *at = actions[0]; <span class="comment">// Assumes actions is not empty</span>
 foreach (QAction *a, actions)
     menu.addAction(a);
 menu.exec(pos, at);</pre>
<p>See also <a href="qmenu.html#popup">popup</a>() and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/focusNextPrevChild"></a>
<h3 class="fn"><a name="focusNextPrevChild"></a>bool QMenu::focusNextPrevChild ( bool <i>next</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/hideEvent"></a>
<h3 class="fn"><a name="hideEvent"></a>void QMenu::hideEvent ( <a href="qhideevent.html">QHideEvent</a> * )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#hideEvent">QWidget::hideEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/hideTearOffMenu"></a>
<h3 class="fn"><a name="hideTearOffMenu"></a>void QMenu::hideTearOffMenu ()</h3>
<p>This function will forcibly hide the torn off menu making it disappear from the users desktop.</p>
<p>See also <a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a>() and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/hovered"></a>
<h3 class="fn"><a name="hovered"></a>void QMenu::hovered ( <a href="qaction.html">QAction</a> * <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when a menu action is highlighted; <i>action</i> is the action that caused the signal to be emitted.</p>
<p>Often this is used to update status information.</p>
<p>See also <a href="qmenu.html#triggered">triggered</a>() and <a href="qaction.html#hovered">QAction::hovered</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/initStyleOption"></a>
<h3 class="fn"><a name="initStyleOption"></a>void QMenu::initStyleOption ( <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a> * <i>option</i>, const <a href="qaction.html">QAction</a> * <i>action</i> ) const&nbsp;&nbsp;<tt> [protected]</tt></h3>
<p>Initialize <i>option</i> with the values from this menu and information from <i>action</i>. This method is useful for subclasses when they need a <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a>, but don't want to fill in all the information themselves.</p>
<p>See also <a href="qstyleoption.html#initFrom">QStyleOption::initFrom</a>() and <a href="qmenubar.html#initStyleOption">QMenuBar::initStyleOption</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/insertMenu"></a>
<h3 class="fn"><a name="insertMenu"></a><a href="qaction.html">QAction</a> * QMenu::insertMenu ( <a href="qaction.html">QAction</a> * <i>before</i>, QMenu * <i>menu</i> )</h3>
<p>This convenience function inserts <i>menu</i> before action <i>before</i> and returns the menus <a href="qmenu.html#menuAction">menuAction</a>().</p>
<p>See also <a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenu.html#addMenu">addMenu</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/insertSeparator"></a>
<h3 class="fn"><a name="insertSeparator"></a><a href="qaction.html">QAction</a> * QMenu::insertSeparator ( <a href="qaction.html">QAction</a> * <i>before</i> )</h3>
<p>This convenience function creates a new separator action, i.e&#x2e; an action with <a href="qaction.html#isSeparator">QAction::isSeparator</a>() returning true. The function inserts the newly created action into this menu's list of actions before action <i>before</i> and returns it.</p>
<p>See also <a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenu.html#addSeparator">addSeparator</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/isEmpty"></a>
<h3 class="fn"><a name="isEmpty"></a>bool QMenu::isEmpty () const</h3>
<p>Returns true if there are no visible actions inserted into the menu, false otherwise.</p>
<p>This function was introduced in Qt 4.2.</p>
<p>See also <a href="qwidget.html#actions">QWidget::actions</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/isTearOffMenuVisible"></a>
<h3 class="fn"><a name="isTearOffMenuVisible"></a>bool QMenu::isTearOffMenuVisible () const</h3>
<p>When a menu is torn off a second menu is shown to display the menu contents in a new window. When the menu is in this mode and the menu is visible returns true; otherwise false.</p>
<p>See also <a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a>() and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/keyPressEvent"></a>
<h3 class="fn"><a name="keyPressEvent"></a>void QMenu::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget::keyPressEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/leaveEvent"></a>
<h3 class="fn"><a name="leaveEvent"></a>void QMenu::leaveEvent ( <a href="qevent.html">QEvent</a> * )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#leaveEvent">QWidget::leaveEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/menuAction"></a>
<h3 class="fn"><a name="menuAction"></a><a href="qaction.html">QAction</a> * QMenu::menuAction () const</h3>
<p>Returns the action associated with this menu.</p>
<a name="//apple_ref/cpp/instm/QMenu/mouseMoveEvent"></a>
<h3 class="fn"><a name="mouseMoveEvent"></a>void QMenu::mouseMoveEvent ( <a href="qmouseevent.html">QMouseEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget::mouseMoveEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/mousePressEvent"></a>
<h3 class="fn"><a name="mousePressEvent"></a>void QMenu::mousePressEvent ( <a href="qmouseevent.html">QMouseEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget::mousePressEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/mouseReleaseEvent"></a>
<h3 class="fn"><a name="mouseReleaseEvent"></a>void QMenu::mouseReleaseEvent ( <a href="qmouseevent.html">QMouseEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget::mouseReleaseEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/paintEvent"></a>
<h3 class="fn"><a name="paintEvent"></a>void QMenu::paintEvent ( <a href="qpaintevent.html">QPaintEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget::paintEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/popup"></a>
<h3 class="fn"><a name="popup"></a>void QMenu::popup ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i>, <a href="qaction.html">QAction</a> * <i>atAction</i> = 0 )</h3>
<p>Displays the menu so that the action <i>atAction</i> will be at the specified <i>global</i> position <i>p</i>. To translate a widget's local coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<p>When positioning a menu with <a href="qmenu.html#exec">exec</a>() or popup(), bear in mind that you cannot rely on the menu's current <a href="qwidget.html#size-prop">size</a>(). For performance reasons, the menu adapts its size only when necessary, so in many cases, the size before and after the show is different. Instead, use <a href="qmenu.html#sizeHint">sizeHint</a>() which calculates the proper size depending on the menu's current contents.</p>
<p>See also <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>() and <a href="qmenu.html#exec">exec</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/setActiveAction"></a>
<h3 class="fn"><a name="setActiveAction"></a>void QMenu::setActiveAction ( <a href="qaction.html">QAction</a> * <i>act</i> )</h3>
<p>Sets the currently highlighted action to <i>act</i>.</p>
<p>See also <a href="qmenu.html#activeAction">activeAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/setDefaultAction"></a>
<h3 class="fn"><a name="setDefaultAction"></a>void QMenu::setDefaultAction ( <a href="qaction.html">QAction</a> * <i>act</i> )</h3>
<p>This sets the default action to <i>act</i>. The default action may have a visual cue, depending on the current <a href="qstyle.html">QStyle</a>. A default action usually indicates what will happen by default when a drop occurs.</p>
<p>See also <a href="qmenu.html#defaultAction">defaultAction</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/sizeHint"></a>
<h3 class="fn"><a name="sizeHint"></a><a href="qsize.html">QSize</a> QMenu::sizeHint () const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget::sizeHint</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/timerEvent"></a>
<h3 class="fn"><a name="timerEvent"></a>void QMenu::timerEvent ( <a href="qtimerevent.html">QTimerEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#timerEvent">QObject::timerEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/triggered"></a>
<h3 class="fn"><a name="triggered"></a>void QMenu::triggered ( <a href="qaction.html">QAction</a> * <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when an action in this menu is triggered.</p>
<p><i>action</i> is the action that caused the signal to be emitted.</p>
<p>Normally, you connect each menu action's <a href="qaction.html#triggered">triggered()</a> signal to its own custom slot, but sometimes you will want to connect several actions to a single slot, for example, when you have a group of closely related actions, such as &quot;left justify&quot;, &quot;center&quot;, &quot;right justify&quot;.</p>
<p><b>Note:</b> This signal is emitted for the main parent menu in a hierarchy. Hence, only the parent menu needs to be connected to a slot; sub-menus need not be connected.</p>
<p>See also <a href="qmenu.html#hovered">hovered</a>() and <a href="qaction.html#triggered">QAction::triggered</a>().</p>
<a name="//apple_ref/cpp/instm/QMenu/wheelEvent"></a>
<h3 class="fn"><a name="wheelEvent"></a>void QMenu::wheelEvent ( <a href="qwheelevent.html">QWheelEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#wheelEvent">QWidget::wheelEvent</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>