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 258 259 260 261 262 263
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QMenuBar Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QMenuBar Class Reference</h1><br clear="all">
<p>
The QMenuBar class provides a horizontal menu bar.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qmenubar-h.html">qmenubar.h</a>></code>
<p>
Inherits <a href="qframe.html">QFrame</a> and <a href="qmenudata.html">QMenuData</a>.
<p><a href="qmenubar-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#a44cc0"><b>QMenuBar</b></a>(QWidget*parent=0, constchar*name=0)</div>
<li><div class="fn"><a href="#c35222"><b>~QMenuBar</b></a>()</div>
<li><div class="fn">virtualvoid<b>updateItem</b>(intid)(internal)</div>
<li><div class="fn">virtualvoid<a href="#572327"><b>show</b></a>()</div>
<li><div class="fn">virtualvoid<a href="#64310d"><b>hide</b></a>()</div>
<li><div class="fn">virtualbool<a href="#041caa"><b>eventFilter</b></a>(QObject*, QEvent*)</div>
<li><div class="fn">virtualint<a href="#ecc869"><b>heightForWidth</b></a>(int)const</div>
<li><div class="fn">enum<a href="#Separator"><b>Separator</b></a>{Never=0, InWindowsStyle=1}</div>
<li><div class="fn">Separator<a href="#ff48a9"><b>separator</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#815978"><b>setSeparator</b></a>(Separatorwhen)</div>
<li><div class="fn">void<a href="#db05df"><b>setDefaultUp</b></a>(bool)</div>
<li><div class="fn">bool<a href="#98ec02"><b>isDefaultUp</b></a>()const</div>
</ul>
<h2>Signals</h2>
<ul>
<li><div class="fn">void<a href="#d2d6e0"><b>activated</b></a>(intitemId)</div>
<li><div class="fn">void<a href="#be9de6"><b>highlighted</b></a>(intitemId)</div>
</ul>
<h2>Important Inherited Members</h2>
<ul>
<li><div class="fn">int<a href="qmenudata.html#230967"><b>insertItem</b></a>(QCustomMenuItem*custom, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#e53049"><b>insertItem</b></a>(QWidget*widget, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#d242f5"><b>insertItem</b></a>(constQIconSet&icon, QCustomMenuItem*custom, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#eab16a"><b>insertItem</b></a>(constQIconSet&icon, constQPixmap&pixmap, QPopupMenu*popup, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#e33289"><b>insertItem</b></a>(constQIconSet&icon, constQPixmap&pixmap, constQObject*receiver, constchar*member, intaccel, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#deddb9"><b>insertItem</b></a>(constQIconSet&icon, constQPixmap&pixmap, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#549faf"><b>insertItem</b></a>(constQIconSet&icon, constQString&text, QPopupMenu*popup, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#033c64"><b>insertItem</b></a>(constQIconSet&icon, constQString&text, constQObject*receiver, constchar*member, intaccel, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#1fb84f"><b>insertItem</b></a>(constQIconSet&icon, constQString&text, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#c8759a"><b>insertItem</b></a>(constQPixmap&pixmap, QPopupMenu*popup, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#c087c8"><b>insertItem</b></a>(constQPixmap&pixmap, constQObject*receiver, constchar*member, intaccel, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#865195"><b>insertItem</b></a>(constQPixmap&pixmap, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#0076cb"><b>insertItem</b></a>(constQString&text, QPopupMenu*popup, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#a0155e"><b>insertItem</b></a>(constQString&text, constQObject*receiver, constchar*member, intaccel, intid, intindex)</div>
<li><div class="fn">int<a href="qmenudata.html#2b0523"><b>insertItem</b></a>(constQString&text, intid, intindex)</div>
<li><div class="fn">void<a href="qmenudata.html#001b53"><b>removeItem</b></a>(intid)</div>
<li><div class="fn">void<a href="qmenudata.html#4bd5e3"><b>clear</b></a>()</div>
<li><div class="fn">int<a href="qmenudata.html#e34b79"><b>insertSeparator</b></a>(intindex)</div>
<li><div class="fn">void<a href="qmenudata.html#c9a23c"><b>setItemEnabled</b></a>(intid, boolenable)</div>
<li><div class="fn">bool<a href="qmenudata.html#f5c40c"><b>isItemEnabled</b></a>(intid)const</div>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class="fn">virtualvoid<a href="#9e8437"><b>drawContents</b></a>(QPainter*)</div>
<li><div class="fn">virtualvoid<b>fontChange</b>(constQFont&)(internal)</div>
<li><div class="fn">virtualvoid<a href="#e308fe"><b>menuContentsChanged</b></a>()</div>
<li><div class="fn">virtualvoid<a href="#74727d"><b>menuStateChanged</b></a>()</div>
</ul>
<h2>Properties</h2>
<table border=1 cellpadding=3 cellspacing=0>
<tr><th>Type<th>Name<th>READ<th>WRITE<th>Options
<tr><td>Separator<td>separator<td>separator<td>setSeparator<td>
<tr><td>bool<td>defaultUp<td>isDefaultUp<td>setDefaultUp<td>
</table>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QMenuBar class provides a horizontal menu bar.
<p>
A menu bar consists of a list of submenu items, so-called pulldown
menus. You add submenu items with <a href="qmenudata.html#0076cb">insertItem</a>(). Assuming that <code>menubar</code> is a pointer to a QMenuBar and <code>filemenu</code> a pointer to a
<a href="qpopupmenu.html">QPopupMenu</a>, <pre> menubar->insertItem( "&File", filemenu );
</pre>
<p>inserts the menu into the menu bar. The ampersand in the item text declares
Alt-f as shortcut for this menu. Use "&&" to get a real ampsend in the menubar.
<p>Items are either enabled or disabled. You toggle their state with
<a href="qmenudata.html#c9a23c">setItemEnabled</a>().
<p>Note that there is no need to layout a menu bar. It automatically
sets its own geometry to the top of the parent widget and changes it
appropriately whenever the parent is resized.
<p><a href="menu-menu-cpp.html#QMenuBar">menu/menu.cpp</a> is a typical example of QMenuBar and QPopupMenu use.
<p><img src=qmenubar-m.png> <img src=qmenubar-w.png>
<p>See also <a href="qpopupmenu.html">QPopupMenu</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Menu Bar</a>
<p>Examples:
<a href="grapher-grapher-cpp.html#QMenuBar">grapher/grapher.cpp</a>
<a href="layout-layout-cpp.html#QMenuBar">layout/layout.cpp</a>
<a href="menu-menu-cpp.html#QMenuBar">menu/menu.cpp</a>
<a href="progress-progress-cpp.html#QMenuBar">progress/progress.cpp</a>
<a href="scrollview-scrollview-cpp.html#QMenuBar">scrollview/scrollview.cpp</a>
<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="Separator">QMenuBar::Separator</a></h3>
This enum type is used to decide whether QMenuBar should draw a
separator line at its bottom. The possible values are: <ul>
<li> <code>Never</code> - in many applications, there already is a separator,
and two looks stupid.
<li> <code>InWindowsStyle</code> - in some other applications, a separator
looks good in Windows style but not else.
<p></ul>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="a44cc0"></a>QMenuBar::QMenuBar(<a href="qwidget.html">QWidget</a>*parent=0, constchar*name=0)</h3>
<p>Constructs a menu bar with a <em>parent</em> and a <em>name.</em>
<h3 class="fn"><a name="c35222"></a>QMenuBar::~QMenuBar()</h3>
<p>Destroys the menu bar.
<h3 class="fn">void<a name="cd3523"></a>QMenuBar::activateItemAt(intindex)</h3>
<p>Reimplemented for internal reasons; the API is not affected.
<h3 class="fn">void<a name="d2d6e0"></a>QMenuBar::activated(intid) <code>[signal]</code></h3>
<p>This signal is emitted when a menu item is selected; <em>id</em> is the id
of the selected item.
<p>Normally, you will connect each menu item to a single slot using
<a href="qmenudata.html#a0155e">QMenuData::insertItem</a>(), but sometimes you will want to connect
several items to a single slot (most often if the user selects from
an array). This signal is handy in such cases.
<p>See also <a href="#be9de6">highlighted</a>() and <a href="qmenudata.html#a0155e">QMenuData::insertItem</a>().
<h3 class="fn">bool<a name="a44d5a"></a>QMenuBar::customWhatsThis()const <code>[virtual]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#eeb880">QWidget.</a>
<h3 class="fn">void<a name="9e8437"></a>QMenuBar::drawContents(<a href="qpainter.html">QPainter</a>*p) <code>[virtualprotected]</code></h3>
<p>Called from <a href="qframe.html#963e1a">QFrame::paintEvent</a>().
<p>Reimplemented from <a href="qframe.html#1991fc">QFrame.</a>
<h3 class="fn">bool<a name="041caa"></a>QMenuBar::eventFilter(<a href="qobject.html">QObject</a>*object, <a href="qevent.html">QEvent</a>*event) <code>[virtual]</code></h3>
<p>This function is used to adjust the menu bar's geometry to the
parent widget's. Note that this is <em>not</em> part of the public
interface - the function is <code>public</code> only because
<a href="qobject.html#bd20fe">QObject::eventFilter</a>() is.
<p>Reimplemented from <a href="qobject.html#bd20fe">QObject.</a>
<h3 class="fn">void<a name="94239f"></a>QMenuBar::focusInEvent(<a href="qfocusevent.html">QFocusEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#21a4b8">QWidget.</a>
<h3 class="fn">void<a name="8e55b7"></a>QMenuBar::focusOutEvent(<a href="qfocusevent.html">QFocusEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#de664a">QWidget.</a>
<h3 class="fn">int<a name="ecc869"></a>QMenuBar::heightForWidth(intmax_width)const <code>[virtual]</code></h3>
<p>Returns the height that the menu would resize itself to if its parent
(and hence itself) resized to the given width. This can be useful for
simple layout tasks where the height of the menubar is needed after
items have been inserted. See examples/showimg/showimg.cpp for an
example of the usage.
<p>Reimplemented from <a href="qwidget.html#1a2d58">QWidget.</a>
<h3 class="fn">void<a name="64310d"></a>QMenuBar::hide() <code>[virtual]</code></h3>
<p>Reimplements <a href="qwidget.html#410481">QWidget::hide</a>() in order to deselect any selected item and
calls setUpLayout() for the mainwindow.
<p>Reimplemented from <a href="qwidget.html#410481">QWidget.</a>
<h3 class="fn">void<a name="be9de6"></a>QMenuBar::highlighted(intid) <code>[signal]</code></h3>
<p>This signal is emitted when a menu item is highlighted; <em>id</em> is the
id of the highlighted item.
<p>Normally, you will connect each menu item to a single slot using
<a href="qmenudata.html#a0155e">QMenuData::insertItem</a>(), but sometimes you will want to connect
several items to a single slot (most often if the user selects from
an array). This signal is handy in such cases.
<p>See also <a href="#d2d6e0">activated</a>() and <a href="qmenudata.html#a0155e">QMenuData::insertItem</a>().
<h3 class="fn">bool<a name="98ec02"></a>QMenuBar::isDefaultUp()const</h3>
<p>Returns whether the menus default to popping "down" the screen
(the default), or "up".
<p>See also <a href="#db05df">setDefaultUp</a>();.
<h3 class="fn">void<a name="a93e50"></a>QMenuBar::keyPressEvent(<a href="qkeyevent.html">QKeyEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#0a4482">QWidget.</a>
<h3 class="fn">void<a name="15f36a"></a>QMenuBar::leaveEvent(<a href="qevent.html">QEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#7eaa8a">QWidget.</a>
<h3 class="fn">void<a name="e308fe"></a>QMenuBar::menuContentsChanged() <code>[virtualprotected]</code></h3>
<p>Recomputes the menu bar's display data according to the new
contents.
<p>You should never need to call this, it is called automatically by
<a href="qmenudata.html">QMenuData</a> whenever it needs to be called.
<p>Reimplemented from <a href="qmenudata.html#f9bfef">QMenuData.</a>
<h3 class="fn">void<a name="74727d"></a>QMenuBar::menuStateChanged() <code>[virtualprotected]</code></h3>
<p>Recomputes the menu bar's display data according to the new
state.
<p>You should never need to call this, it is called automatically by
<a href="qmenudata.html">QMenuData</a> whenever it needs to be called.
<p>Reimplemented from <a href="qmenudata.html#402fb8">QMenuData.</a>
<h3 class="fn"><a href="qsize.html">QSize</a><a name="be0c20"></a>QMenuBar::minimumSize()const</h3>
<p>Reimplemented for internal reasons; the API is not affected.
<h3 class="fn"><a href="qsize.html">QSize</a><a name="33423d"></a>QMenuBar::minimumSizeHint()const <code>[virtual]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#553e08">QWidget.</a>
<h3 class="fn">void<a name="50b34a"></a>QMenuBar::mouseMoveEvent(<a href="qmouseevent.html">QMouseEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#a51d92">QWidget.</a>
<h3 class="fn">void<a name="8a5755"></a>QMenuBar::mousePressEvent(<a href="qmouseevent.html">QMouseEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#2ecc04">QWidget.</a>
<h3 class="fn">void<a name="3c5f28"></a>QMenuBar::mouseReleaseEvent(<a href="qmouseevent.html">QMouseEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#9aa77f">QWidget.</a>
<h3 class="fn">void<a name="6b5ce9"></a>QMenuBar::resizeEvent(<a href="qresizeevent.html">QResizeEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#7d375f">QWidget.</a>
<h3 class="fn">QMenuBar::Separator<a name="ff48a9"></a>QMenuBar::separator()const</h3>
<p>Returns the currently set <a href="#Separator">Separator</a> usage.
<p>See also <a href="#Separator">Separator</a> and <a href="#815978">setSeparator</a>().
<h3 class="fn">void<a name="db05df"></a>QMenuBar::setDefaultUp(boolon)</h3>
<p>Sets the default popup orientation. By default, menus pop "down" the
screen. By calling setDefaultUp(TRUE) the menu will pop "up". You
might call this for menus that are <em>below</em> the document to which
they refer.
<p>If the menu would not fit on the screen, the other direction is used
rather than the default.
<p>See also defaultUp();.
<h3 class="fn">void<a name="815978"></a>QMenuBar::setSeparator(<a href="qmenubar.html#Separator">Separator</a>when)</h3>
<p>When a menubar is used above an unframed widget, it may look better
with a separating line when displayed with <a href="qwidget.html#027381">WindowsStyle</a>.
<p>This function sets the usage of such a separator to appear either
QMenuBar::Never, or QMenuBar::InWindowsStyle.
<p>The default is QMenuBar::Never.
<p>See also <a href="#Separator">Separator</a> and <a href="#ff48a9">separator</a>().
<p>Examples:
<a href="layout-layout-cpp.html#setSeparator">layout/layout.cpp</a>
<a href="scrollview-scrollview-cpp.html#setSeparator">scrollview/scrollview.cpp</a>
<h3 class="fn">void<a name="572327"></a>QMenuBar::show() <code>[virtual]</code></h3>
<p>Reimplements <a href="qwidget.html#200ee5">QWidget::show</a>() in order to set up the correct keyboard
accelerators and raise itself to the top of the widget stack.
<p>Reimplemented from <a href="qwidget.html#200ee5">QWidget.</a>
<h3 class="fn"><a href="qsize.html">QSize</a><a name="62f3bb"></a>QMenuBar::sizeHint()const <code>[virtual]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#4511d1">QWidget.</a>
<h3 class="fn">void<a name="9d6d66"></a>QMenuBar::styleChange(<a href="qstyle.html">QStyle</a>&old) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#5e2e23">QWidget.</a>
<h3 class="fn">void<a name="15ea9b"></a>QMenuBar::fontChange(const<a href="qfont.html">QFont</a>&f) <code>[virtualprotected]</code></h3>
<p>For internal use only.
<p>Reimplemented from <a href="qwidget.html#ac5c83">QWidget.</a>
<h3 class="fn">void<a name="736fda"></a>QMenuBar::updateItem(intid) <code>[virtual]</code></h3>
<p>For internal use only.
<p>Reimplemented from <a href="qmenudata.html#f532d3">QMenuData.</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|