File: qmenubar.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (87 lines) | stat: -rw-r--r-- 18,554 bytes parent folder | download
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QMenuBar Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QMenuBar Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QMenuBar class provides a horizontal menu bar. <a href="#details">More...</a></p>
<p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmenubar.html#QMenuBar">__init__</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#actionAt">actionAt</a></b> (<i>self</i>, QPoint)</li><li><div class="fn" /><b><a href="qmenubar.html#actionEvent">actionEvent</a></b> (<i>self</i>, QActionEvent)</li><li><div class="fn" />QRect <b><a href="qmenubar.html#actionGeometry">actionGeometry</a></b> (<i>self</i>, QAction)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#activeAction">activeAction</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenubar.html#addAction">addAction</a></b> (<i>self</i>, QAction&#160;<i>action</i>)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#addAction-2">addAction</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#addAction-3">addAction</a></b> (<i>self</i>, QString&#160;<i>text</i>, QObject&#160;<i>receiver</i>, SLOT()&#160;<i>member</i>)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#addAction-4">addAction</a></b> (<i>self</i>, QString&#160;<i>text</i>, callable&#160;<i>receiver</i>)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#addMenu">addMenu</a></b> (<i>self</i>, QMenu&#160;<i>menu</i>)</li><li><div class="fn" />QMenu <b><a href="qmenubar.html#addMenu-2">addMenu</a></b> (<i>self</i>, QString&#160;<i>title</i>)</li><li><div class="fn" />QMenu <b><a href="qmenubar.html#addMenu-3">addMenu</a></b> (<i>self</i>, QIcon&#160;<i>icon</i>, QString&#160;<i>title</i>)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#addSeparator">addSeparator</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenubar.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qmenubar.html#cornerWidget">cornerWidget</a></b> (<i>self</i>, Qt.Corner&#160;<i>corner</i>&#160;=&#160;Qt.TopRightCorner)</li><li><div class="fn" />bool <b><a href="qmenubar.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />bool <b><a href="qmenubar.html#eventFilter">eventFilter</a></b> (<i>self</i>, QObject, QEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#focusInEvent">focusInEvent</a></b> (<i>self</i>, QFocusEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#focusOutEvent">focusOutEvent</a></b> (<i>self</i>, QFocusEvent)</li><li><div class="fn" />int <b><a href="qmenubar.html#heightForWidth">heightForWidth</a></b> (<i>self</i>, int)</li><li><div class="fn" />QAction <b><a href="qmenubar.html#insertMenu">insertMenu</a></b> (<i>self</i>, QAction&#160;<i>before</i>, QMenu&#160;<i>menu</i>)</li><li><div class="fn" />bool <b><a href="qmenubar.html#isDefaultUp">isDefaultUp</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenubar.html#keyPressEvent">keyPressEvent</a></b> (<i>self</i>, QKeyEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#leaveEvent">leaveEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />QSize <b><a href="qmenubar.html#minimumSizeHint">minimumSizeHint</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenubar.html#mouseMoveEvent">mouseMoveEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#mouseReleaseEvent">mouseReleaseEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent)</li><li><div class="fn" /><b><a href="qmenubar.html#setActiveAction">setActiveAction</a></b> (<i>self</i>, QAction&#160;<i>action</i>)</li><li><div class="fn" /><b><a href="qmenubar.html#setCornerWidget">setCornerWidget</a></b> (<i>self</i>, QWidget&#160;<i>w</i>, Qt.Corner&#160;<i>corner</i>&#160;=&#160;Qt.TopRightCorner)</li><li><div class="fn" /><b><a href="qmenubar.html#setDefaultUp">setDefaultUp</a></b> (<i>self</i>, bool)</li><li><div class="fn" />QSize <b><a href="qmenubar.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qmenubar.html#hovered">hovered</a></b> (QAction *)</li><li><div class="fn" />void <b><a href="qmenubar.html#triggered">triggered</a></b> (QAction *)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QMenuBar class provides a horizontal menu bar.</p>
<p>A menu bar consists of a list of pull-down menu items. You add menu items with <a href="qmenubar.html#addMenu">addMenu</a>(). For example, asuming that <tt>menubar</tt> is a pointer to a QMenuBar and <tt>fileMenu</tt> is a pointer to a <a href="qmenu.html">QMenu</a>, the following statement inserts the menu into the menu bar:</p>
<pre>
    menubar-&gt;addMenu(fileMenu);
</pre>
<p>The ampersand in the menu item's text sets Alt+F as a shortcut for this menu. (You can use "&amp;&amp;" to get a real ampersand in the menu bar.)</p>
<p>There is no need to lay out 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>
<p>In most main window style applications you would use the menuBar() provided in <a href="qmainwindow.html">QMainWindow</a>, adding <a href="qmenu.html">QMenu</a>s to the menu bar and adding <a href="qaction.html">QAction</a>s to the popup menus.</p>
<p>Example (from the <a href="mainwindows-menus.html">Menus</a> example):</p>
<pre>
        fileMenu = menuBar()-&gt;addMenu(tr("&amp;File"));
        fileMenu-&gt;addAction(newAct);
</pre>
<p>Menu items may be removed with <a href="qwidget.html#removeAction">removeAction</a>().</p>
<p align="center"><img alt="A menubar shown in the Motif widget style." src="images/motif-menubar.png" /></p>
<p align="center"><img alt="A menubar shown in the Plastique widget style." src="images/plastique-menubar.png" /></p>
<a id="qmenubar-on-qt-mac" name="qmenubar-on-qt-mac" />
<h3>QMenuBar on Qt/Mac</h3>
<p>QMenuBar on Qt/Mac is a wrapper for using the system-wide menubar. If you have multiple menubars in one dialog the outermost menubar (normally inside a widget with widget flag <a href="qt.html#WindowType-enum">Qt.Window</a>) will be used for the system-wide menubar.</p>
<p>Qt/Mac also provides a menubar merging feature to make QMenuBar conform more closely to accepted Mac OS X menubar layout. The merging functionality is based on string matching the title of a <a href="qmenu.html">QMenu</a> entry. These strings are translated (using <a href="qobject.html#tr">QObject.tr</a>()) in the "QMenuBar" context. If an entry is moved its slots will still fire as if it was in the original place. The table below outlines the strings looked for and where the entry is placed if matched:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>String matches</th>
<th>Placement</th>
<th>Notes</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>about.*</td>
<td>Application Menu | About &lt;application name&gt;</td>
<td>If this entry is not found no About item will appear in the Application Menu</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>config, options, setup, settings or preferences</td>
<td>Application Menu | Preferences</td>
<td>If this entry is not found the Settings item will be disabled</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>quit or exit</td>
<td>Application Menu | Quit &lt;application name&gt;</td>
<td>If this entry is not found a default Quit item will be created to call <a href="qcoreapplication.html#quit">QApplication.quit</a>()</td>
</tr>
</table>
<br />
<br />
<p>The <a href="mainwindows-menus.html">Menus</a> example shows how to use QMenuBar and <a href="qmenu.html">QMenu</a>.</p>
<p>{fowler}{GUI Design Handbook: Menu Bar}</p>
<p>See also <a href="qmenu.html">QMenu</a>, <a href="qshortcut.html">QShortcut</a>, <a href="qaction.html">QAction</a>, and <a href="http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html">Introduction to Apple Human Interface Guidelines</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QMenuBar" />QMenuBar.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a menu bar with parent <i>parent</i>.</p>
<h3 class="fn"><a name="actionAt" /><a href="qaction.html">QAction</a> QMenuBar.actionAt (<i>self</i>, <a href="qpoint.html">QPoint</a>)</h3><h3 class="fn"><a name="actionEvent" />QMenuBar.actionEvent (<i>self</i>, <a href="qactionevent.html">QActionEvent</a>)</h3><h3 class="fn"><a name="actionGeometry" /><a href="qrect.html">QRect</a> QMenuBar.actionGeometry (<i>self</i>, <a href="qaction.html">QAction</a>)</h3><h3 class="fn"><a name="activeAction" /><a href="qaction.html">QAction</a> QMenuBar.activeAction (<i>self</i>)</h3><p>Returns the <a href="qaction.html">QAction</a> that is currently highlighted. A null pointer will be returned if no action is currently selected.</p>
<p>See also <a href="qmenubar.html#setActiveAction">setActiveAction</a>().</p>
<h3 class="fn"><a name="addAction" />QMenuBar.addAction (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>)</h3><p>This convenience function creates a new action with <i>text</i>. The function adds the newly created action to the menu's list of actions, and returns it.</p>
<p>See also <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>
<h3 class="fn"><a name="addAction-2" /><a href="qaction.html">QAction</a> QMenuBar.addAction (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This convenience function creates a new action with the given <i>text</i>. The action's <a href="qmenubar.html#triggered">triggered</a>() signal is connected to the <i>receiver</i>'s <i>member</i> slot. The function adds the newly created action to the menu's list of actions and returns it.</p>
<p>See also <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>
<h3 class="fn"><a name="addAction-3" /><a href="qaction.html">QAction</a> QMenuBar.addAction (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qobject.html">QObject</a>&#160;<i>receiver</i>, SLOT()&#160;<i>member</i>)</h3><h3 class="fn"><a name="addAction-4" /><a href="qaction.html">QAction</a> QMenuBar.addAction (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, callable&#160;<i>receiver</i>)</h3><h3 class="fn"><a name="addMenu" /><a href="qaction.html">QAction</a> QMenuBar.addMenu (<i>self</i>, <a href="qmenu.html">QMenu</a>&#160;<i>menu</i>)</h3><p>Appends <i>menu</i> to the menubar. Returns the menu's menuAction().</p>
<p>See also <a href="qwidget.html#addAction">QWidget.addAction</a>() and <a href="qmenu.html#menuAction">QMenu.menuAction</a>().</p>
<h3 class="fn"><a name="addMenu-2" /><a href="qmenu.html">QMenu</a> QMenuBar.addMenu (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>title</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Appends a new <a href="qmenu.html">QMenu</a> with <i>title</i> to the menubar. The menubar takes ownership of the menu. Returns the new menu.</p>
<p>See also <a href="qwidget.html#addAction">QWidget.addAction</a>() and <a href="qmenu.html#menuAction">QMenu.menuAction</a>().</p>
<h3 class="fn"><a name="addMenu-3" /><a href="qmenu.html">QMenu</a> QMenuBar.addMenu (<i>self</i>, <a href="qicon.html">QIcon</a>&#160;<i>icon</i>, <a href="qstring.html">QString</a>&#160;<i>title</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Appends a new <a href="qmenu.html">QMenu</a> with <i>icon</i> and <i>title</i> to the menubar. The menubar takes ownership of the menu. Returns the new menu.</p>
<p>See also <a href="qwidget.html#addAction">QWidget.addAction</a>() and <a href="qmenu.html#menuAction">QMenu.menuAction</a>().</p>
<h3 class="fn"><a name="addSeparator" /><a href="qaction.html">QAction</a> QMenuBar.addSeparator (<i>self</i>)</h3><p>Appends a separator to the menu.</p>
<h3 class="fn"><a name="changeEvent" />QMenuBar.changeEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="clear" />QMenuBar.clear (<i>self</i>)</h3><p>Removes all the actions from the menu bar.</p>
<p>See also <a href="qwidget.html#removeAction">removeAction</a>().</p>
<h3 class="fn"><a name="cornerWidget" /><a href="qwidget.html">QWidget</a> QMenuBar.cornerWidget (<i>self</i>, <a href="qt.html#Corner-enum">Qt.Corner</a>&#160;<i>corner</i>&#160;=&#160;Qt.TopRightCorner)</h3><h3 class="fn"><a name="event" />bool QMenuBar.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="eventFilter" />bool QMenuBar.eventFilter (<i>self</i>, <a href="qobject.html">QObject</a>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="focusInEvent" />QMenuBar.focusInEvent (<i>self</i>, <a href="qfocusevent.html">QFocusEvent</a>)</h3><h3 class="fn"><a name="focusOutEvent" />QMenuBar.focusOutEvent (<i>self</i>, <a href="qfocusevent.html">QFocusEvent</a>)</h3><h3 class="fn"><a name="heightForWidth" />int QMenuBar.heightForWidth (<i>self</i>, int)</h3><h3 class="fn"><a name="insertMenu" /><a href="qaction.html">QAction</a> QMenuBar.insertMenu (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>before</i>, <a href="qmenu.html">QMenu</a>&#160;<i>menu</i>)</h3><p>This convenience function inserts <i>menu</i> before action <i>before</i> and returns the menus menuAction().</p>
<p>See also <a href="qwidget.html#insertAction">QWidget.insertAction</a>() and <a href="qmenubar.html#addMenu">addMenu</a>().</p>
<h3 class="fn"><a name="isDefaultUp" />bool QMenuBar.isDefaultUp (<i>self</i>)</h3><h3 class="fn"><a name="keyPressEvent" />QMenuBar.keyPressEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a>)</h3><h3 class="fn"><a name="leaveEvent" />QMenuBar.leaveEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="minimumSizeHint" /><a href="qsize.html">QSize</a> QMenuBar.minimumSizeHint (<i>self</i>)</h3><h3 class="fn"><a name="mouseMoveEvent" />QMenuBar.mouseMoveEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><h3 class="fn"><a name="mousePressEvent" />QMenuBar.mousePressEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><h3 class="fn"><a name="mouseReleaseEvent" />QMenuBar.mouseReleaseEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><h3 class="fn"><a name="paintEvent" />QMenuBar.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>)</h3><h3 class="fn"><a name="resizeEvent" />QMenuBar.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>)</h3><h3 class="fn"><a name="setActiveAction" />QMenuBar.setActiveAction (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>)</h3><p>Sets the currently highlighted action to <i>act</i>.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qmenubar.html#activeAction">activeAction</a>().</p>
<h3 class="fn"><a name="setCornerWidget" />QMenuBar.setCornerWidget (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>w</i>, <a href="qt.html#Corner-enum">Qt.Corner</a>&#160;<i>corner</i>&#160;=&#160;Qt.TopRightCorner)</h3><h3 class="fn"><a name="setDefaultUp" />QMenuBar.setDefaultUp (<i>self</i>, bool)</h3><h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QMenuBar.sizeHint (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="hovered" />void hovered (QAction *)</h3><p>This signal is emitted when a menu action is highlighted; <i>action</i> is the action that caused the event to be sent.</p>
<p>Often this is used to update status information.</p>
<p>See also <a href="qmenubar.html#triggered">triggered</a>() and <a href="qaction.html#hovered">QAction.hovered</a>().</p>
<h3 class="fn"><a name="triggered" />void triggered (QAction *)</h3><p>This signal is emitted when a menu action is selected; <i>action</i> is the action that caused the event to be sent.</p>
<p>Normally, you connect each menu action to a single slot using <a href="qaction.html#triggered">QAction.triggered</a>(), but sometimes you will want to connect several items to a single slot (most often if the user selects from an array). This signal is useful in such cases.</p>
<p>See also <a href="qmenubar.html#hovered">hovered</a>() and <a href="qaction.html#triggered">QAction.triggered</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>