/usr/share/qt5/doc/qtquickcontrols/qml-qtquick-controls-menu.html is in qtquickcontrols5-doc-html 5.5.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Menu.qml -->
<title>Menu QML Type | Qt Quick Controls 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtquickcontrols-index.html">Qt Quick Controls</a></li>
<li><a href="qtquick-controls-qmlmodule.html">QML Types</a></li>
<li>Menu QML Type</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</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="#signals">Signals</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Menu QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Menu-brief -->
<p>Provides a menu component for use as a context menu, popup menu, or as part of a menu bar. <a href="#details">More...</a></p>
<!-- @@@Menu -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick.Controls 1.4</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.1</td></tr></table></div><ul>
<li><a href="qml-qtquick-controls-menu-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#enabled-prop">enabled</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#iconName-prop">iconName</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#iconSource-prop">iconSource</a></b></b> : url</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#items-prop">items</a></b></b> : list<Object></li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#style-prop">style</a></b></b> : Component</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#title-prop">title</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#type-prop">type</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#visible-prop">visible</a></b></b> : bool</li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#aboutToHide-signal">aboutToHide</a></b></b>()</li>
<li class="fn"><b><b><a href="qml-qtquick-controls-menu.html#aboutToShow-signal">aboutToShow</a></b></b>()</li>
</ul>
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
<li class="fn">MenuItem <b><b><a href="qml-qtquick-controls-menu.html#addItem-method">addItem</a></b></b>(string <i> text</i>)</li>
<li class="fn">Menu <b><b><a href="qml-qtquick-controls-menu.html#addMenu-method">addMenu</a></b></b>(string <i> title</i>)</li>
<li class="fn">void <b><b><a href="qml-qtquick-controls-menu.html#addSeparator-method">addSeparator</a></b></b>()</li>
<li class="fn">void <b><b><a href="qml-qtquick-controls-menu.html#insertItem-method-2">insertItem</a></b></b>(int <i> before</i>, object <i> item</i>)</li>
<li class="fn">MenuItem <b><b><a href="qml-qtquick-controls-menu.html#insertItem-method">insertItem</a></b></b>(int <i> before</i>, string <i> title</i>)</li>
<li class="fn">MenuItem <b><b><a href="qml-qtquick-controls-menu.html#insertMenu-method">insertMenu</a></b></b>(int <i> before</i>, string <i> title</i>)</li>
<li class="fn">void <b><b><a href="qml-qtquick-controls-menu.html#insertSeparator-method">insertSeparator</a></b></b>(int <i> before</i>)</li>
<li class="fn">void <b><b><a href="qml-qtquick-controls-menu.html#popup-method">popup</a></b></b>()</li>
<li class="fn">void <b><b><a href="qml-qtquick-controls-menu.html#removeItem-method">removeItem</a></b></b>(item)</li>
</ul>
<!-- $$$Menu-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
</p>
<p class="centerAlign"><img src="images/menu.png" alt="" /></p><pre class="cpp">Menu {
title: <span class="string">"Edit"</span>
MenuItem {
text: <span class="string">"Cut"</span>
shortcut: <span class="string">"Ctrl+X"</span>
onTriggered: <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
MenuItem {
text: <span class="string">"Copy"</span>
shortcut: <span class="string">"Ctrl+C"</span>
onTriggered: <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
MenuItem {
text: <span class="string">"Paste"</span>
shortcut: <span class="string">"Ctrl+V"</span>
onTriggered: <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
MenuSeparator { }
Menu {
title: <span class="string">"More Stuff"</span>
MenuItem {
text: <span class="string">"Do Nothing"</span>
}
}
}</pre>
<p>The main uses for menus:</p>
<ul>
<li>as a <i>top-level</i> menu in a <a href="qml-qtquick-controls-menubar.html">MenuBar</a></li>
<li>as a <i>submenu</i> inside another menu</li>
<li>as a standalone or <i>context</i> menu</li>
</ul>
<p>Note that some properties, such as <code>enabled</code>, <code>text</code>, or <code>iconSource</code>, only make sense in a particular use case of the menu.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menubar.html">MenuBar</a>, <a href="qml-qtquick-controls-menuitem.html">MenuItem</a>, and <a href="qml-qtquick-controls-menuseparator.html">MenuSeparator</a>.</p>
<!-- @@@Menu -->
<h2>Property Documentation</h2>
<!-- $$$enabled -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="enabled-prop"><td class="tblQmlPropNode"><p><a name="enabled-prop"></a><span class="name">enabled</span> : <span class="type">bool</span></p></td></tr></table></div></div><div class="qmldoc"><p>Whether the menu is enabled, and responsive to user interaction as a submenu. Its value defaults to <code>true</code>.</p>
</div></div><!-- @@@enabled -->
<br/>
<!-- $$$iconName -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="iconName-prop"><td class="tblQmlPropNode"><p><a name="iconName-prop"></a><span class="name">iconName</span> : <span class="type">string</span></p></td></tr></table></div></div><div class="qmldoc"><p>Sets the icon name for the menu icon. This will pick the icon with the given name from the current theme. Only works as a submenu.</p>
<p>Its value defaults to the empty string.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#iconSource-prop">iconSource</a>.</p>
</div></div><!-- @@@iconName -->
<br/>
<!-- $$$iconSource -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="iconSource-prop"><td class="tblQmlPropNode"><p><a name="iconSource-prop"></a><span class="name">iconSource</span> : <span class="type"><a href="../qtqml/qml-url.html">url</a></span></p></td></tr></table></div></div><div class="qmldoc"><p>Sets the icon file or resource url for the menu icon as a submenu. Defaults to the empty URL.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#iconName-prop">iconName</a>.</p>
</div></div><!-- @@@iconSource -->
<br/>
<!-- $$$items -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="items-prop"><td class="tblQmlPropNode"><p><a name="items-prop"></a><span class="qmldefault">default</span><span class="name">items</span> : <span class="type">list</span><<span class="type">Object</span>></p></td></tr></table></div></div><div class="qmldoc"><p>The list of items in the menu.</p>
<p><a href="qml-qtquick-controls-menu.html">Menu</a> only accepts objects of type <a href="qml-qtquick-controls-menu.html">Menu</a>, <a href="qml-qtquick-controls-menuitem.html">MenuItem</a>, and <a href="qml-qtquick-controls-menuseparator.html">MenuSeparator</a> as children. It also supports <a href="../qtqml/qml-qtqml-instantiator.html">Instantiator</a> objects as long as the insertion is being done manually using <a href="qml-qtquick-controls-menu.html#insertItem-method">insertItem()</a>.</p>
<pre class="cpp">Menu {
id: recentFilesMenu
Instantiator {
model: recentFilesModel
MenuItem {
text: model<span class="operator">.</span>fileName
}
onObjectAdded: recentFilesMenu<span class="operator">.</span>insertItem(index<span class="operator">,</span> object)
onObjectRemoved: recentFilesMenu<span class="operator">.</span>removeItem(object)
}
MenuSeparator {
visible: recentFilesModel<span class="operator">.</span>count <span class="operator">></span> <span class="number">0</span>
}
MenuItem {
text: <span class="string">"Clear menu"</span>
enabled: recentFilesModel<span class="operator">.</span>count <span class="operator">></span> <span class="number">0</span>
onTriggered: recentFilesModel<span class="operator">.</span>clear()
}</pre>
<p>Note that in this case, the <code>index</code> parameter passed to <a href="qml-qtquick-controls-menu.html#insertItem-method">insertItem()</a> is relative to the position of the <a href="../qtqml/qml-qtqml-instantiator.html">Instantiator</a> in the menu, as opposed to absolute position in the menu.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menuitem.html">MenuItem</a> and <a href="qml-qtquick-controls-menuseparator.html">MenuSeparator</a>.</p>
</div></div><!-- @@@items -->
<br/>
<!-- $$$style -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="style-prop"><td class="tblQmlPropNode"><p><a name="style-prop"></a><span class="name">style</span> : <span class="type"><a href="../qtqml/qml-qtqml-component.html">Component</a></span></p></td></tr></table></div></div><div class="qmldoc"><p>The style Component for this control.</p>
<p>This QML property was introduced in QtQuick.Controls.Styles 1.2.</p>
<p><b>See also </b><a href="qml-qtquick-controls-styles-menustyle.html">MenuStyle</a>.</p>
</div></div><!-- @@@style -->
<br/>
<!-- $$$title -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="title-prop"><td class="tblQmlPropNode"><p><a name="title-prop"></a><span class="name">title</span> : <span class="type">string</span></p></td></tr></table></div></div><div class="qmldoc"><p>Title for the menu as a submenu or in a menubar.</p>
<p>Mnemonics are supported by prefixing the shortcut letter with &. For instance, <code>"\&File"</code> will bind the <code>Alt-F</code> shortcut to the <code>"File"</code> menu. Note that not all platforms support mnemonics.</p>
<p>Its value defaults to the empty string.</p>
</div></div><!-- @@@title -->
<br/>
<!-- $$$type -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="type-prop"><td class="tblQmlPropNode"><p><a name="type-prop"></a><span class="name">type</span> : <span class="type">enumeration</span></p></td></tr></table></div></div><div class="qmldoc"><p>This property is read-only and constant, and its value is <a href="qml-qtquick-controls-menuitem.html#type-prop">type</a>.</p>
</div></div><!-- @@@type -->
<br/>
<!-- $$$visible -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="visible-prop"><td class="tblQmlPropNode"><p><a name="visible-prop"></a><span class="name">visible</span> : <span class="type">bool</span></p></td></tr></table></div></div><div class="qmldoc"><p>Whether the menu should be visible as a submenu of another Menu, or as a menu on a <a href="qml-qtquick-controls-menubar.html">MenuBar</a>. Its value defaults to <code>true</code>.</p>
<p><b>Note: </b>This has nothing to do with the actual menu pop-up window being visible. Use aboutToShow() and aboutToHide() if you need to know when the pop-up window will be shown or hidden.</p></div></div><!-- @@@visible -->
<br/>
<h2>Signal Documentation</h2>
<!-- $$$aboutToHide -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="aboutToHide-signal"><td class="tblQmlFuncNode"><p><a name="aboutToHide-signal"></a><span class="name">aboutToHide</span>()</p></td></tr></table></div></div><div class="qmldoc"><p>This signal is emitted just before the menu is hidden from the user.</p>
<p>This QML signal was introduced in QtQuick.Controls 1.4.</p>
<p><b>See also </b>aboutToShow().</p>
</div></div><!-- @@@aboutToHide -->
<br/>
<!-- $$$aboutToShow -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="aboutToShow-signal"><td class="tblQmlFuncNode"><p><a name="aboutToShow-signal"></a><span class="name">aboutToShow</span>()</p></td></tr></table></div></div><div class="qmldoc"><p>This signal is emitted just before the menu is shown to the user.</p>
<p>This QML signal was introduced in QtQuick.Controls 1.4.</p>
<p><b>See also </b>aboutToHide().</p>
</div></div><!-- @@@aboutToShow -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$addItem -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="addItem-method"><td class="tblQmlFuncNode"><p><a name="addItem-method"></a><span class="type"><a href="qml-qtquick-controls-menuitem.html">MenuItem</a></span> <span class="name">addItem</span>(<span class="type">string</span><i> text</i>)</p></td></tr></table></div></div><div class="qmldoc"><p>Adds an item to the menu. Returns the newly created <a href="qml-qtquick-controls-menuitem.html">MenuItem</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#insertItem-method">insertItem()</a>.</p>
</div></div><!-- @@@addItem -->
<br/>
<!-- $$$addMenu -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="addMenu-method"><td class="tblQmlFuncNode"><p><a name="addMenu-method"></a><span class="type"><a href="qml-qtquick-controls-menu.html">Menu</a></span> <span class="name">addMenu</span>(<span class="type">string</span><i> title</i>)</p></td></tr></table></div></div><div class="qmldoc"><p>Adds a submenu to the menu. Returns the newly created <a href="qml-qtquick-controls-menu.html">Menu</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#insertMenu-method">insertMenu()</a>.</p>
</div></div><!-- @@@addMenu -->
<br/>
<!-- $$$addSeparator -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="addSeparator-method"><td class="tblQmlFuncNode"><p><a name="addSeparator-method"></a><span class="type">void</span> <span class="name">addSeparator</span>()</p></td></tr></table></div></div><div class="qmldoc"><p>Adds a separator to the menu.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#insertSeparator-method">insertSeparator()</a>.</p>
</div></div><!-- @@@addSeparator -->
<br/>
<!-- $$$insertItem -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="insertItem-method-2"><td class="tblQmlFuncNode"><p><a name="insertItem-method-2"></a><span class="type">void</span> <span class="name">insertItem</span>(<span class="type">int</span><i> before</i>, <span class="type">object</span><i> item</i>)</p></td></tr></table></div></div><div class="qmldoc"><p>Inserts the <code>item</code> at the index <code>before</code> in the current menu. In this case, <code>item</code> can be either a <a href="qml-qtquick-controls-menuitem.html">MenuItem</a>, a <a href="qml-qtquick-controls-menuseparator.html">MenuSeparator</a>, or a <a href="qml-qtquick-controls-menu.html">Menu</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#removeItem-method">removeItem()</a>.</p>
</div></div><!-- @@@insertItem -->
<br/>
<!-- $$$insertItem -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="insertItem-method"><td class="tblQmlFuncNode"><p><a name="insertItem-method"></a><span class="type"><a href="qml-qtquick-controls-menuitem.html">MenuItem</a></span> <span class="name">insertItem</span>(<span class="type">int</span><i> before</i>, <span class="type">string</span><i> title</i>)</p></td></tr></table></div></div><div class="qmldoc"><p>Creates and inserts an item with title <code>title</code> at the index <code>before</code> in the current menu. Returns the newly created <a href="qml-qtquick-controls-menuitem.html">MenuItem</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#addItem-method">addItem()</a>.</p>
</div></div><!-- @@@insertItem -->
<br/>
<!-- $$$insertMenu -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="insertMenu-method"><td class="tblQmlFuncNode"><p><a name="insertMenu-method"></a><span class="type"><a href="qml-qtquick-controls-menuitem.html">MenuItem</a></span> <span class="name">insertMenu</span>(<span class="type">int</span><i> before</i>, <span class="type">string</span><i> title</i>)</p></td></tr></table></div></div><div class="qmldoc"><p>Creates and inserts a submenu with title <code>title</code> at the index <code>before</code> in the current menu. Returns the newly created <a href="qml-qtquick-controls-menu.html">Menu</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#addMenu-method">addMenu()</a>.</p>
</div></div><!-- @@@insertMenu -->
<br/>
<!-- $$$insertSeparator -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="insertSeparator-method"><td class="tblQmlFuncNode"><p><a name="insertSeparator-method"></a><span class="type">void</span> <span class="name">insertSeparator</span>(<span class="type">int</span><i> before</i>)</p></td></tr></table></div></div><div class="qmldoc"><p>Creates and inserts a separator at the index <code>before</code> in the current menu.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#addSeparator-method">addSeparator()</a>.</p>
</div></div><!-- @@@insertSeparator -->
<br/>
<!-- $$$popup -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="popup-method"><td class="tblQmlFuncNode"><p><a name="popup-method"></a><span class="type">void</span> <span class="name">popup</span>()</p></td></tr></table></div></div><div class="qmldoc"><p>Opens this menu under the mouse cursor. It can block on some platforms, so test it accordingly.</p>
</div></div><!-- @@@popup -->
<br/>
<!-- $$$removeItem -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="removeItem-method"><td class="tblQmlFuncNode"><p><a name="removeItem-method"></a><span class="type">void</span> <span class="name">removeItem</span>(<span class="type">item</span>)</p></td></tr></table></div></div><div class="qmldoc"><p>Removes the <code>item</code> from the menu. In this case, <code>item</code> can be either a <a href="qml-qtquick-controls-menuitem.html">MenuItem</a>, a <a href="qml-qtquick-controls-menuseparator.html">MenuSeparator</a>, or a <a href="qml-qtquick-controls-menu.html">Menu</a>.</p>
<p><b>See also </b><a href="qml-qtquick-controls-menu.html#insertItem-method">insertItem()</a>.</p>
</div></div><!-- @@@removeItem -->
<br/>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 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>
|