Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 3440

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmenu.cpp -->
  <title>QMenu Class | Qt Widgets 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QMenu</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#actions">Actions</a></li>
<li class="level2"><a href="#qmenu-on-macos-with-qt-build-against-cocoa">QMenu on macOS with Qt Build Against Cocoa</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QMenu Class</h1>
<!-- $$$QMenu-brief -->
<p>The <a href="qmenu.html">QMenu</a> class provides a menu widget for use in menu bars, context menus, and other popup menus. <a href="#details">More...</a></p>
<!-- @@@QMenu -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QMenu&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qwidget.html">QWidget</a></td></tr></table></div><ul>
<li><a href="qmenu-members.html">List of all members, including inherited members</a></li>
<li><a href="qmenu-obsolete.html">Obsolete members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<div class="table"><table class="propsummary">
<tr><td class="topAlign"><ul>
<li class="fn"><b><a href="qmenu.html#icon-prop">icon</a></b> : QIcon</li>
<li class="fn"><b><a href="qmenu.html#separatorsCollapsible-prop">separatorsCollapsible</a></b> : bool</li>
<li class="fn"><b><a href="qmenu.html#tearOffEnabled-prop">tearOffEnabled</a></b> : bool</li>
</ul></td><td class="topAlign"><ul>
<li class="fn"><b><a href="qmenu.html#title-prop">title</a></b> : QString</li>
<li class="fn"><b><a href="qmenu.html#toolTipsVisible-prop">toolTipsVisible</a></b> : bool</li>
</ul>
</td></tr>
</table></div>
<ul>
<li class="fn">59 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#QMenu">QMenu</a></b>(QWidget *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#QMenu-1">QMenu</a></b>(const QString &amp;<i>title</i>, QWidget *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#dtor.QMenu">~QMenu</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#actionAt">actionAt</a></b>(const QPoint &amp;<i>pt</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#actionGeometry">actionGeometry</a></b>(QAction *<i>act</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#activeAction">activeAction</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction">addAction</a></b>(const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-1">addAction</a></b>(const QIcon &amp;<i>icon</i>, const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-2">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 rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-3">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 rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-4">addAction</a></b>(const QString &amp;<i>text</i>, const QObject *<i>receiver</i>, PointerToMemberFunction <i>method</i>, const QKeySequence &amp;<i>shortcut</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-5">addAction</a></b>(const QString &amp;<i>text</i>, Functor <i>functor</i>, const QKeySequence &amp;<i>shortcut</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-6">addAction</a></b>(const QString &amp;<i>text</i>, const QObject *<i>context</i>, Functor <i>functor</i>, const QKeySequence &amp;<i>shortcut</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-7">addAction</a></b>(const QIcon &amp;<i>icon</i>, const QString &amp;<i>text</i>, const QObject *<i>receiver</i>, PointerToMemberFunction <i>method</i>, const QKeySequence &amp;<i>shortcut</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-8">addAction</a></b>(const QIcon &amp;<i>icon</i>, const QString &amp;<i>text</i>, Functor <i>functor</i>, const QKeySequence &amp;<i>shortcut</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addAction-9">addAction</a></b>(const QIcon &amp;<i>icon</i>, const QString &amp;<i>text</i>, const QObject *<i>context</i>, Functor <i>functor</i>, const QKeySequence &amp;<i>shortcut</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addMenu">addMenu</a></b>(QMenu *<i>menu</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMenu *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addMenu-1">addMenu</a></b>(const QString &amp;<i>title</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMenu *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addMenu-2">addMenu</a></b>(const QIcon &amp;<i>icon</i>, const QString &amp;<i>title</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addSection">addSection</a></b>(const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addSection-1">addSection</a></b>(const QIcon &amp;<i>icon</i>, const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#addSeparator">addSeparator</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#clear">clear</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#defaultAction">defaultAction</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#exec">exec</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#exec-1">exec</a></b>(const QPoint &amp;<i>p</i>, QAction *<i>action</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QIcon </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#icon-prop">icon</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#insertMenu">insertMenu</a></b>(QAction *<i>before</i>, QMenu *<i>menu</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#insertSection">insertSection</a></b>(QAction *<i>before</i>, const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#insertSection-1">insertSection</a></b>(QAction *<i>before</i>, const QIcon &amp;<i>icon</i>, const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#insertSeparator">insertSeparator</a></b>(QAction *<i>before</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#isEmpty">isEmpty</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#menuAction">menuAction</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#popup">popup</a></b>(const QPoint &amp;<i>p</i>, QAction *<i>atAction</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#separatorsCollapsible-prop">separatorsCollapsible</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#setActiveAction">setActiveAction</a></b>(QAction *<i>act</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#setAsDockMenu">setAsDockMenu</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#setDefaultAction">setDefaultAction</a></b>(QAction *<i>act</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#icon-prop">setIcon</a></b>(const QIcon &amp;<i>icon</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#separatorsCollapsible-prop">setSeparatorsCollapsible</a></b>(bool <i>collapse</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#tearOffEnabled-prop">setTearOffEnabled</a></b>(<i>bool</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#title-prop">setTitle</a></b>(const QString &amp;<i>title</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#toolTipsVisible-prop">setToolTipsVisible</a></b>(bool <i>visible</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#showTearOffMenu">showTearOffMenu</a></b>(const QPoint &amp;<i>pos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#showTearOffMenu-1">showTearOffMenu</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#title-prop">title</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> NSMenu *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#toNSMenu">toNSMenu</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#toolTipsVisible-prop">toolTipsVisible</a></b>() const</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSize </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#sizeHint">sizeHint</a></b>() const</td></tr>
</table></div>
<ul>
<li class="fn">214 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li class="fn">32 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li>
<li class="fn">14 public functions inherited from <a href="../qtgui/qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#aboutToHide">aboutToHide</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#aboutToShow">aboutToShow</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#hovered">hovered</a></b>(QAction *<i>action</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#triggered">triggered</a></b>(QAction *<i>action</i>)</td></tr>
</table></div>
<ul>
<li class="fn">3 signals inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QAction *</td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#exec-2">exec</a></b>(QList&lt;QAction *&gt; <i>actions</i>, const QPoint &amp;<i>pos</i>, QAction *<i>at</i> = Q_NULLPTR, QWidget *<i>parent</i> = Q_NULLPTR)</td></tr>
</table></div>
<ul>
<li class="fn">5 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h2 id="protected-functions">Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#columnCount">columnCount</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#initStyleOption">initStyleOption</a></b>(QStyleOptionMenuItem *<i>option</i>, const QAction *<i>action</i>) const</td></tr>
</table></div>
<a name="reimplemented-protected-functions"></a>
<h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#actionEvent">actionEvent</a></b>(QActionEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#changeEvent">changeEvent</a></b>(QEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#enterEvent">enterEvent</a></b>(<i>QEvent *</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#event">event</a></b>(QEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#focusNextPrevChild">focusNextPrevChild</a></b>(bool <i>next</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#hideEvent">hideEvent</a></b>(<i>QHideEvent *</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#keyPressEvent">keyPressEvent</a></b>(QKeyEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#leaveEvent">leaveEvent</a></b>(<i>QEvent *</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#mouseMoveEvent">mouseMoveEvent</a></b>(QMouseEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#mousePressEvent">mousePressEvent</a></b>(QMouseEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#mouseReleaseEvent">mouseReleaseEvent</a></b>(QMouseEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#paintEvent">paintEvent</a></b>(QPaintEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#timerEvent">timerEvent</a></b>(QTimerEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmenu.html#wheelEvent">wheelEvent</a></b>(QWheelEvent *<i>e</i>)</td></tr>
</table></div>
<ul>
<li class="fn">35 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="../qtgui/qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li>
<li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li>
<li class="fn">1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
<li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li>
<li class="fn">1 protected type inherited from <a href="../qtgui/qpaintdevice.html#protected-variables">QPaintDevice</a></li>
</ul>
<a name="details"></a>
<!-- $$$QMenu-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qmenu.html">QMenu</a> class provides a menu widget for use in menu bars, context menus, and other popup menus.</p>
<p class="centerAlign"><img src="images/fusion-menu.png" alt="" /></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>
<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, <a href="qmenu.html">QMenu</a> provides two signals, <a href="qmenu.html#triggered">triggered</a>() and <a href="qmenu.html#hovered">hovered</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 <a href="qmenu.html">QMenu</a> 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>
<p><b>Warning:</b> To make <a href="qmenu.html">QMenu</a> visible on the screen, <a href="qmenu.html#exec">exec</a>() or <a href="qmenu.html#popup">popup</a>() should be used instead of <a href="qwidget.html#show">show</a>().</p>
<a name="qmenu-on-macos-with-qt-build-against-cocoa"></a>
<h3 >QMenu on macOS with Qt Build Against Cocoa</h3>
<p><a href="qmenu.html">QMenu</a> 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="qtwidgets-mainwindows-menus-example.html">Menus</a> example for an example of how to use <a href="qmenubar.html">QMenuBar</a> and <a href="qmenu.html">QMenu</a> 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>
</div>
<p><b>See also </b><a href="qmenubar.html">QMenuBar</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Menu, Drop-Down and Pop-Up</a>, <a href="qtwidgets-mainwindows-application-example.html">Application Example</a>, and <a href="qtwidgets-mainwindows-menus-example.html">Menus Example</a>.</p>
<!-- @@@QMenu -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$icon-prop$$$icon$$$setIconconstQIcon& -->
<h3 class="fn" id="icon-prop"><a name="icon-prop"></a><span class="name">icon</span> : <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span></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>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QIcon </td><td class="memItemRight bottomAlign"><span class="name"><b>icon</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setIcon</b></span>(const QIcon &amp;<i>icon</i>)</td></tr>
</table></div>
<!-- @@@icon -->
<!-- $$$separatorsCollapsible-prop$$$separatorsCollapsible$$$setSeparatorsCollapsiblebool -->
<h3 class="fn" id="separatorsCollapsible-prop"><a name="separatorsCollapsible-prop"></a><span class="name">separatorsCollapsible</span> : <span class="type">bool</span></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 <code>true</code>.</p>
<p>This property was introduced in  Qt 4.2.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>separatorsCollapsible</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setSeparatorsCollapsible</b></span>(bool <i>collapse</i>)</td></tr>
</table></div>
<!-- @@@separatorsCollapsible -->
<!-- $$$tearOffEnabled-prop$$$isTearOffEnabled$$$setTearOffEnabledbool -->
<h3 class="fn" id="tearOffEnabled-prop"><a name="tearOffEnabled-prop"></a><span class="name">tearOffEnabled</span> : <span class="type">bool</span></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 <code>false</code>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>isTearOffEnabled</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTearOffEnabled</b></span>(<i>bool</i>)</td></tr>
</table></div>
<!-- @@@tearOffEnabled -->
<!-- $$$title-prop$$$title$$$setTitleconstQString& -->
<h3 class="fn" id="title-prop"><a name="title-prop"></a><span class="name">title</span> : <span class="type"><a href="../qtcore/qstring.html">QString</a></span></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>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>title</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTitle</b></span>(const QString &amp;<i>title</i>)</td></tr>
</table></div>
<!-- @@@title -->
<!-- $$$toolTipsVisible-prop$$$toolTipsVisible$$$setToolTipsVisiblebool -->
<h3 class="fn" id="toolTipsVisible-prop"><a name="toolTipsVisible-prop"></a><span class="name">toolTipsVisible</span> : <span class="type">bool</span></h3>
<p>This property holds whether tooltips of menu actions should be visible</p>
<p>This property specifies whether action menu entries show their tooltip.</p>
<p>By default, this property is <code>false</code>.</p>
<p>This property was introduced in  Qt 5.1.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>toolTipsVisible</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setToolTipsVisible</b></span>(bool <i>visible</i>)</td></tr>
</table></div>
<!-- @@@toolTipsVisible -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMenu[overload1]$$$QMenuQWidget* -->
<h3 class="fn" id="QMenu"><a name="QMenu"></a>QMenu::<span class="name">QMenu</span>(<span class="type"><a href="qwidget.html#QWidget">QWidget</a></span> *<i>parent</i> = Q_NULLPTR)</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="../qtcore/qobject.html">QObject</a>).</p>
<!-- @@@QMenu -->
<!-- $$$QMenu$$$QMenuconstQString&QWidget* -->
<h3 class="fn" id="QMenu-1"><a name="QMenu-1"></a>QMenu::<span class="name">QMenu</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>title</i>, <span class="type"><a href="qwidget.html#QWidget">QWidget</a></span> *<i>parent</i> = Q_NULLPTR)</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="../qtcore/qobject.html">QObject</a>).</p>
<p><b>See also </b><a href="qmenu.html#title-prop">title</a>.</p>
<!-- @@@QMenu -->
<!-- $$$~QMenu[overload1]$$$~QMenu -->
<h3 class="fn" id="dtor.QMenu"><a name="dtor.QMenu"></a>QMenu::<span class="name">~QMenu</span>()</h3>
<p>Destroys the menu.</p>
<!-- @@@~QMenu -->
<!-- $$$aboutToHide[overload1]$$$aboutToHide -->
<h3 class="fn" id="aboutToHide"><a name="aboutToHide"></a><code>[signal] </code><span class="type">void</span> QMenu::<span class="name">aboutToHide</span>()</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><b>See also </b><a href="qmenu.html#aboutToShow">aboutToShow</a>() and <a href="qwidget.html#hide">hide</a>().</p>
<!-- @@@aboutToHide -->
<!-- $$$aboutToShow[overload1]$$$aboutToShow -->
<h3 class="fn" id="aboutToShow"><a name="aboutToShow"></a><code>[signal] </code><span class="type">void</span> QMenu::<span class="name">aboutToShow</span>()</h3>
<p>This signal is emitted just before the menu is shown to the user.</p>
<p><b>See also </b><a href="qmenu.html#aboutToHide">aboutToHide</a>() and <a href="qwidget.html#show">show</a>().</p>
<!-- @@@aboutToShow -->
<!-- $$$actionAt[overload1]$$$actionAtconstQPoint& -->
<h3 class="fn" id="actionAt"><a name="actionAt"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">actionAt</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>pt</i>) const</h3>
<p>Returns the item at <i>pt</i>; returns 0 if there is no item there.</p>
<!-- @@@actionAt -->
<!-- $$$actionEvent[overload1]$$$actionEventQActionEvent* -->
<h3 class="fn" id="actionEvent"><a name="actionEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">actionEvent</span>(<span class="type"><a href="../qtgui/qactionevent.html">QActionEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#actionEvent">QWidget::actionEvent</a>().</p>
<!-- @@@actionEvent -->
<!-- $$$actionGeometry[overload1]$$$actionGeometryQAction* -->
<h3 class="fn" id="actionGeometry"><a name="actionGeometry"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QMenu::<span class="name">actionGeometry</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>act</i>) const</h3>
<p>Returns the geometry of action <i>act</i>.</p>
<!-- @@@actionGeometry -->
<!-- $$$activeAction[overload1]$$$activeAction -->
<h3 class="fn" id="activeAction"><a name="activeAction"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">activeAction</span>() const</h3>
<p>Returns the currently highlighted action, or 0 if no action is currently highlighted.</p>
<p><b>See also </b><a href="qmenu.html#setActiveAction">setActiveAction</a>().</p>
<!-- @@@activeAction -->
<!-- $$$addAction[overload1]$$$addActionconstQString& -->
<h3 class="fn" id="addAction"><a name="addAction"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &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><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQIcon&constQString& -->
<h3 class="fn" id="addAction-1"><a name="addAction-1"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &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><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQString&constQObject*constchar*constQKeySequence& -->
<h3 class="fn" id="addAction-2"><a name="addAction-2"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, const <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type">char</span> *<i>member</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQIcon&constQString&constQObject*constchar*constQKeySequence& -->
<h3 class="fn" id="addAction-3"><a name="addAction-3"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, const <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type">char</span> *<i>member</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQString&constQObject*PointerToMemberFunctionconstQKeySequence& -->
<h3 class="fn" id="addAction-4"><a name="addAction-4"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, const <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type">PointerToMemberFunction</span> <i>method</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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>method</i> of the <i>receiver</i>. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQString&FunctorconstQKeySequence& -->
<h3 class="fn" id="addAction-5"><a name="addAction-5"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, <span class="type">Functor</span> <i>functor</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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>functor</i>. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQString&constQObject*FunctorconstQKeySequence& -->
<h3 class="fn" id="addAction-6"><a name="addAction-6"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, const <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>context</i>, <span class="type">Functor</span> <i>functor</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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>functor</i>. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p>If <i>context</i> is destroyed, the functor will not be called.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQIcon&constQString&constQObject*PointerToMemberFunctionconstQKeySequence& -->
<h3 class="fn" id="addAction-7"><a name="addAction-7"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, const <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type">PointerToMemberFunction</span> <i>method</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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>method</i> of the <i>receiver</i>. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQIcon&constQString&FunctorconstQKeySequence& -->
<h3 class="fn" id="addAction-8"><a name="addAction-8"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, <span class="type">Functor</span> <i>functor</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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>functor</i>. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@addAction -->
<!-- $$$addAction$$$addActionconstQIcon&constQString&constQObject*FunctorconstQKeySequence& -->
<h3 class="fn" id="addAction-9"><a name="addAction-9"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addAction</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>, const <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>context</i>, <span class="type">Functor</span> <i>functor</i>, const <span class="type"><a href="../qtgui/qkeysequence.html">QKeySequence</a></span> &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>functor</i>. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p>If <i>context</i> is destroyed, the functor will not be called.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@addAction -->
<!-- $$$addMenu[overload1]$$$addMenuQMenu* -->
<h3 class="fn" id="addMenu"><a name="addMenu"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addMenu</span>(<span class="type"><a href="qmenu.html#QMenu">QMenu</a></span> *<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><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
<!-- @@@addMenu -->
<!-- $$$addMenu$$$addMenuconstQString& -->
<h3 class="fn" id="addMenu-1"><a name="addMenu-1"></a><span class="type"><a href="qmenu.html#QMenu">QMenu</a></span> *QMenu::<span class="name">addMenu</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &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><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
<!-- @@@addMenu -->
<!-- $$$addMenu$$$addMenuconstQIcon&constQString& -->
<h3 class="fn" id="addMenu-2"><a name="addMenu-2"></a><span class="type"><a href="qmenu.html#QMenu">QMenu</a></span> *QMenu::<span class="name">addMenu</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &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><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
<!-- @@@addMenu -->
<!-- $$$addSection[overload1]$$$addSectionconstQString& -->
<h3 class="fn" id="addSection"><a name="addSection"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addSection</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>)</h3>
<p>This convenience function creates a new section action, i.e&#x2e; an action with <a href="qaction.html#isSeparator">QAction::isSeparator</a>() returning true but also having <i>text</i> hint, and adds the new action to this menu's list of actions. It returns the newly created action.</p>
<p>The rendering of the hint is style and platform dependent. Widget styles can use the text information in the rendering for sections, or can choose to ignore it and render sections like simple separators.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addSection -->
<!-- $$$addSection$$$addSectionconstQIcon&constQString& -->
<h3 class="fn" id="addSection-1"><a name="addSection-1"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addSection</span>(const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>)</h3>
<p>This convenience function creates a new section action, i.e&#x2e; an action with <a href="qaction.html#isSeparator">QAction::isSeparator</a>() returning true but also having <i>text</i> and <i>icon</i> hints, and adds the new action to this menu's list of actions. It returns the newly created action.</p>
<p>The rendering of the hints is style and platform dependent. Widget styles can use the text and icon information in the rendering for sections, or can choose to ignore them and render sections like simple separators.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addSection -->
<!-- $$$addSeparator[overload1]$$$addSeparator -->
<h3 class="fn" id="addSeparator"><a name="addSeparator"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">addSeparator</span>()</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><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p><b>See also </b><a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
<!-- @@@addSeparator -->
<!-- $$$changeEvent[overload1]$$$changeEventQEvent* -->
<h3 class="fn" id="changeEvent"><a name="changeEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">changeEvent</span>(<span class="type"><a href="../qtcore/qevent.html">QEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget::changeEvent</a>().</p>
<!-- @@@changeEvent -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn" id="clear"><a name="clear"></a><span class="type">void</span> QMenu::<span class="name">clear</span>()</h3>
<p>Removes all the menu's actions. Actions owned by the menu and not shown in any other widget are deleted.</p>
<p><b>See also </b><a href="qwidget.html#removeAction">removeAction</a>().</p>
<!-- @@@clear -->
<!-- $$$columnCount[overload1]$$$columnCount -->
<h3 class="fn" id="columnCount"><a name="columnCount"></a><code>[protected] </code><span class="type">int</span> QMenu::<span class="name">columnCount</span>() const</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>
<!-- @@@columnCount -->
<!-- $$$defaultAction[overload1]$$$defaultAction -->
<h3 class="fn" id="defaultAction"><a name="defaultAction"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">defaultAction</span>() const</h3>
<p>Returns the current default action.</p>
<p><b>See also </b><a href="qmenu.html#setDefaultAction">setDefaultAction</a>().</p>
<!-- @@@defaultAction -->
<!-- $$$enterEvent[overload1]$$$enterEventQEvent* -->
<h3 class="fn" id="enterEvent"><a name="enterEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">enterEvent</span>(<i>QEvent *</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#enterEvent">QWidget::enterEvent</a>().</p>
<!-- @@@enterEvent -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn" id="event"><a name="event"></a><code>[virtual protected] </code><span class="type">bool</span> QMenu::<span class="name">event</span>(<span class="type"><a href="../qtcore/qevent.html">QEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="../qtcore/qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$exec[overload1]$$$exec -->
<h3 class="fn" id="exec"><a name="exec"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">exec</span>()</h3>
<p>Executes this menu synchronously.</p>
<p>This is equivalent to <code>exec(pos())</code>.</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 class="cpp">

  exec(<span class="type"><a href="../qtgui/qcursor.html">QCursor</a></span><span class="operator">::</span>pos());

</pre>
<p>or aligned to a widget:</p>
<pre class="cpp">

  exec(somewidget<span class="operator">.</span>mapToGlobal(<span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span>(<span class="number">0</span><span class="operator">,</span><span class="number">0</span>)));

</pre>
<p>or in reaction to a <a href="../qtgui/qmouseevent.html">QMouseEvent</a> *e:</p>
<pre class="cpp">

  exec(e<span class="operator">-</span><span class="operator">&gt;</span>globalPos());

</pre>
<!-- @@@exec -->
<!-- $$$exec$$$execconstQPoint&QAction* -->
<h3 class="fn" id="exec-1"><a name="exec-1"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">exec</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>p</i>, <span class="type"><a href="qaction.html">QAction</a></span> *<i>action</i> = Q_NULLPTR)</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 class="cpp">

  exec(<span class="type"><a href="../qtgui/qcursor.html">QCursor</a></span><span class="operator">::</span>pos());

</pre>
<p>or aligned to a widget:</p>
<pre class="cpp">

  exec(somewidget<span class="operator">.</span>mapToGlobal(<span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span>)));

</pre>
<p>or in reaction to a <a href="../qtgui/qmouseevent.html">QMouseEvent</a> *e:</p>
<pre class="cpp">

  exec(e<span class="operator">-</span><span class="operator">&gt;</span>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><b>See also </b><a href="qmenu.html#popup">popup</a>() and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<!-- @@@exec -->
<!-- $$$exec$$$execQList<QAction*>constQPoint&QAction*QWidget* -->
<h3 class="fn" id="exec-2"><a name="exec-2"></a><code>[static] </code><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">exec</span>(<span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qaction.html">QAction</a></span> *&gt; <i>actions</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>pos</i>, <span class="type"><a href="qaction.html">QAction</a></span> *<i>at</i> = Q_NULLPTR, <span class="type"><a href="qwidget.html#QWidget">QWidget</a></span> *<i>parent</i> = Q_NULLPTR)</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 class="cpp">

  <span class="type"><a href="qmenu.html#QMenu">QMenu</a></span> menu;
  <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>at <span class="operator">=</span> actions<span class="operator">[</span><span class="number">0</span><span class="operator">]</span>; <span class="comment">// Assumes actions is not empty</span>
  foreach (<span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>a<span class="operator">,</span> actions)
      menu<span class="operator">.</span>addAction(a);
  menu<span class="operator">.</span>exec(pos<span class="operator">,</span> at);

</pre>
<p><b>See also </b><a href="qmenu.html#popup">popup</a>() and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().</p>
<!-- @@@exec -->
<!-- $$$focusNextPrevChild[overload1]$$$focusNextPrevChildbool -->
<h3 class="fn" id="focusNextPrevChild"><a name="focusNextPrevChild"></a><code>[virtual protected] </code><span class="type">bool</span> QMenu::<span class="name">focusNextPrevChild</span>(<span class="type">bool</span> <i>next</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>().</p>
<!-- @@@focusNextPrevChild -->
<!-- $$$hideEvent[overload1]$$$hideEventQHideEvent* -->
<h3 class="fn" id="hideEvent"><a name="hideEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">hideEvent</span>(<i>QHideEvent *</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#hideEvent">QWidget::hideEvent</a>().</p>
<!-- @@@hideEvent -->
<!-- $$$hideTearOffMenu[overload1]$$$hideTearOffMenu -->
<h3 class="fn" id="hideTearOffMenu"><a name="hideTearOffMenu"></a><span class="type">void</span> QMenu::<span class="name">hideTearOffMenu</span>()</h3>
<p>This function will forcibly hide the torn off menu making it disappear from the user's desktop.</p>
<p><b>See also </b><a href="qmenu.html#showTearOffMenu-1">showTearOffMenu</a>(), <a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a>(), and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>
<!-- @@@hideTearOffMenu -->
<!-- $$$hovered[overload1]$$$hoveredQAction* -->
<h3 class="fn" id="hovered"><a name="hovered"></a><code>[signal] </code><span class="type">void</span> QMenu::<span class="name">hovered</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>action</i>)</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><b>See also </b><a href="qmenu.html#triggered">triggered</a>() and <a href="qaction.html#hovered">QAction::hovered</a>().</p>
<!-- @@@hovered -->
<!-- $$$initStyleOption[overload1]$$$initStyleOptionQStyleOptionMenuItem*constQAction* -->
<h3 class="fn" id="initStyleOption"><a name="initStyleOption"></a><code>[protected] </code><span class="type">void</span> QMenu::<span class="name">initStyleOption</span>(<span class="type"><a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a></span> *<i>option</i>, const <span class="type"><a href="qaction.html">QAction</a></span> *<i>action</i>) const</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><b>See also </b><a href="qstyleoption.html#initFrom">QStyleOption::initFrom</a>() and <a href="qmenubar.html#initStyleOption">QMenuBar::initStyleOption</a>().</p>
<!-- @@@initStyleOption -->
<!-- $$$insertMenu[overload1]$$$insertMenuQAction*QMenu* -->
<h3 class="fn" id="insertMenu"><a name="insertMenu"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">insertMenu</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>before</i>, <span class="type"><a href="qmenu.html#QMenu">QMenu</a></span> *<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><b>See also </b><a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenu.html#addMenu">addMenu</a>().</p>
<!-- @@@insertMenu -->
<!-- $$$insertSection[overload1]$$$insertSectionQAction*constQString& -->
<h3 class="fn" id="insertSection"><a name="insertSection"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">insertSection</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>before</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>)</h3>
<p>This convenience function creates a new title action, i.e&#x2e; an action with <a href="qaction.html#isSeparator">QAction::isSeparator</a>() returning true but also having <i>text</i> hint. The function inserts the newly created action into this menu's list of actions before action <i>before</i> and returns it.</p>
<p>The rendering of the hint is style and platform dependent. Widget styles can use the text information in the rendering for sections, or can choose to ignore it and render sections like simple separators.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenu.html#addSection">addSection</a>().</p>
<!-- @@@insertSection -->
<!-- $$$insertSection$$$insertSectionQAction*constQIcon&constQString& -->
<h3 class="fn" id="insertSection-1"><a name="insertSection-1"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">insertSection</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>before</i>, const <span class="type"><a href="../qtgui/qicon.html">QIcon</a></span> &amp;<i>icon</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>text</i>)</h3>
<p>This convenience function creates a new title action, i.e&#x2e; an action with <a href="qaction.html#isSeparator">QAction::isSeparator</a>() returning true but also having <i>text</i> and <i>icon</i> hints. The function inserts the newly created action into this menu's list of actions before action <i>before</i> and returns it.</p>
<p>The rendering of the hints is style and platform dependent. Widget styles can use the text and icon information in the rendering for sections, or can choose to ignore them and render sections like simple separators.</p>
<p><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenu.html#addSection">addSection</a>().</p>
<!-- @@@insertSection -->
<!-- $$$insertSeparator[overload1]$$$insertSeparatorQAction* -->
<h3 class="fn" id="insertSeparator"><a name="insertSeparator"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">insertSeparator</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<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><a href="qmenu.html">QMenu</a> takes ownership of the returned <a href="qaction.html">QAction</a>.</p>
<p><b>See also </b><a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenu.html#addSeparator">addSeparator</a>().</p>
<!-- @@@insertSeparator -->
<!-- $$$isEmpty[overload1]$$$isEmpty -->
<h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QMenu::<span class="name">isEmpty</span>() const</h3>
<p>Returns <code>true</code> if there are no visible actions inserted into the menu, false otherwise.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qwidget.html#actions">QWidget::actions</a>().</p>
<!-- @@@isEmpty -->
<!-- $$$isTearOffMenuVisible[overload1]$$$isTearOffMenuVisible -->
<h3 class="fn" id="isTearOffMenuVisible"><a name="isTearOffMenuVisible"></a><span class="type">bool</span> QMenu::<span class="name">isTearOffMenuVisible</span>() 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 <code>true</code>; otherwise false.</p>
<p><b>See also </b><a href="qmenu.html#showTearOffMenu-1">showTearOffMenu</a>(), <a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a>(), and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>
<!-- @@@isTearOffMenuVisible -->
<!-- $$$keyPressEvent[overload1]$$$keyPressEventQKeyEvent* -->
<h3 class="fn" id="keyPressEvent"><a name="keyPressEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">keyPressEvent</span>(<span class="type"><a href="../qtgui/qkeyevent.html">QKeyEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget::keyPressEvent</a>().</p>
<!-- @@@keyPressEvent -->
<!-- $$$leaveEvent[overload1]$$$leaveEventQEvent* -->
<h3 class="fn" id="leaveEvent"><a name="leaveEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">leaveEvent</span>(<i>QEvent *</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#leaveEvent">QWidget::leaveEvent</a>().</p>
<!-- @@@leaveEvent -->
<!-- $$$menuAction[overload1]$$$menuAction -->
<h3 class="fn" id="menuAction"><a name="menuAction"></a><span class="type"><a href="qaction.html">QAction</a></span> *QMenu::<span class="name">menuAction</span>() const</h3>
<p>Returns the action associated with this menu.</p>
<!-- @@@menuAction -->
<!-- $$$mouseMoveEvent[overload1]$$$mouseMoveEventQMouseEvent* -->
<h3 class="fn" id="mouseMoveEvent"><a name="mouseMoveEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">mouseMoveEvent</span>(<span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget::mouseMoveEvent</a>().</p>
<!-- @@@mouseMoveEvent -->
<!-- $$$mousePressEvent[overload1]$$$mousePressEventQMouseEvent* -->
<h3 class="fn" id="mousePressEvent"><a name="mousePressEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">mousePressEvent</span>(<span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget::mousePressEvent</a>().</p>
<!-- @@@mousePressEvent -->
<!-- $$$mouseReleaseEvent[overload1]$$$mouseReleaseEventQMouseEvent* -->
<h3 class="fn" id="mouseReleaseEvent"><a name="mouseReleaseEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">mouseReleaseEvent</span>(<span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget::mouseReleaseEvent</a>().</p>
<!-- @@@mouseReleaseEvent -->
<!-- $$$paintEvent[overload1]$$$paintEventQPaintEvent* -->
<h3 class="fn" id="paintEvent"><a name="paintEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">paintEvent</span>(<span class="type"><a href="../qtgui/qpaintevent.html">QPaintEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget::paintEvent</a>().</p>
<!-- @@@paintEvent -->
<!-- $$$popup[overload1]$$$popupconstQPoint&QAction* -->
<h3 class="fn" id="popup"><a name="popup"></a><span class="type">void</span> QMenu::<span class="name">popup</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>p</i>, <span class="type"><a href="qaction.html">QAction</a></span> *<i>atAction</i> = Q_NULLPTR)</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><b>See also </b><a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>() and <a href="qmenu.html#exec">exec</a>().</p>
<!-- @@@popup -->
<!-- $$$setActiveAction[overload1]$$$setActiveActionQAction* -->
<h3 class="fn" id="setActiveAction"><a name="setActiveAction"></a><span class="type">void</span> QMenu::<span class="name">setActiveAction</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>act</i>)</h3>
<p>Sets the currently highlighted action to <i>act</i>.</p>
<p><b>See also </b><a href="qmenu.html#activeAction">activeAction</a>().</p>
<!-- @@@setActiveAction -->
<!-- $$$setAsDockMenu[overload1]$$$setAsDockMenu -->
<h3 class="fn" id="setAsDockMenu"><a name="setAsDockMenu"></a><span class="type">void</span> QMenu::<span class="name">setAsDockMenu</span>()</h3>
<p>Set this menu to be the dock menu available by option-clicking on the application dock icon. Available on macOS only.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@setAsDockMenu -->
<!-- $$$setDefaultAction[overload1]$$$setDefaultActionQAction* -->
<h3 class="fn" id="setDefaultAction"><a name="setDefaultAction"></a><span class="type">void</span> QMenu::<span class="name">setDefaultAction</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<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><b>See also </b><a href="qmenu.html#defaultAction">defaultAction</a>().</p>
<!-- @@@setDefaultAction -->
<!-- $$$showTearOffMenu[overload1]$$$showTearOffMenuconstQPoint& -->
<h3 class="fn" id="showTearOffMenu"><a name="showTearOffMenu"></a><span class="type">void</span> QMenu::<span class="name">showTearOffMenu</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>pos</i>)</h3>
<p>This function will forcibly show the torn off menu making it appear on the user's desktop at the specified <i>global</i> position <i>pos</i>.</p>
<p>This function was introduced in  Qt 5.7.</p>
<p><b>See also </b><a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a>(), <a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a>(), and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>
<!-- @@@showTearOffMenu -->
<!-- $$$showTearOffMenu$$$showTearOffMenu -->
<h3 class="fn" id="showTearOffMenu-1"><a name="showTearOffMenu-1"></a><span class="type">void</span> QMenu::<span class="name">showTearOffMenu</span>()</h3>
<p>This is an overloaded function.</p>
<p>This function will forcibly show the torn off menu making it appear on the user's desktop under the mouse currsor.</p>
<p>This function was introduced in  Qt 5.7.</p>
<p><b>See also </b><a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a>(), <a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a>(), and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>
<!-- @@@showTearOffMenu -->
<!-- $$$sizeHint[overload1]$$$sizeHint -->
<h3 class="fn" id="sizeHint"><a name="sizeHint"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QMenu::<span class="name">sizeHint</span>() const</h3>
<p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget::sizeHint</a>().</p>
<!-- @@@sizeHint -->
<!-- $$$timerEvent[overload1]$$$timerEventQTimerEvent* -->
<h3 class="fn" id="timerEvent"><a name="timerEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">timerEvent</span>(<span class="type"><a href="../qtcore/qtimerevent.html">QTimerEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="../qtcore/qobject.html#timerEvent">QObject::timerEvent</a>().</p>
<!-- @@@timerEvent -->
<!-- $$$toNSMenu[overload1]$$$toNSMenu -->
<h3 class="fn" id="toNSMenu"><a name="toNSMenu"></a><span class="type">NSMenu</span> *QMenu::<span class="name">toNSMenu</span>()</h3>
<p>Returns the native NSMenu for this menu. Available on macOS only.</p>
<p><b>Note: </b>Qt sets the delegate on the native menu. If you need to set your own delegate, make sure you save the original one and forward any calls to it.</p><p>This function was introduced in  Qt 5.2.</p>
<!-- @@@toNSMenu -->
<!-- $$$triggered[overload1]$$$triggeredQAction* -->
<h3 class="fn" id="triggered"><a name="triggered"></a><code>[signal] </code><span class="type">void</span> QMenu::<span class="name">triggered</span>(<span class="type"><a href="qaction.html">QAction</a></span> *<i>action</i>)</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><b>See also </b><a href="qmenu.html#hovered">hovered</a>() and <a href="qaction.html#triggered">QAction::triggered</a>().</p>
<!-- @@@triggered -->
<!-- $$$wheelEvent[overload1]$$$wheelEventQWheelEvent* -->
<h3 class="fn" id="wheelEvent"><a name="wheelEvent"></a><code>[virtual protected] </code><span class="type">void</span> QMenu::<span class="name">wheelEvent</span>(<span class="type"><a href="../qtgui/qwheelevent.html">QWheelEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qwidget.html#wheelEvent">QWidget::wheelEvent</a>().</p>
<!-- @@@wheelEvent -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>