~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qmenubar.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/widgets/qmenubar.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QMenuBar Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QMenuBar Class Reference</h1>
 
21
<p>The QMenuBar class provides a horizontal menu bar. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QMenuBar&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qwidget.html">QWidget</a>.</p>
 
24
<ul>
 
25
<li><a href="qmenubar-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qmenubar-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="properties"></a>
 
29
<h3>Properties</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="qmenubar.html#defaultUp-prop">defaultUp</a></b> : bool</li>
 
32
</ul>
 
33
<ul>
 
34
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
 
35
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
36
</ul>
 
37
<a name="public-functions"></a>
 
38
<h3>Public Functions</h3>
 
39
<ul>
 
40
<li><div class="fn"/><b><a href="qmenubar.html#QMenuBar">QMenuBar</a></b> ( QWidget * <i>parent</i> = 0 )</li>
 
41
<li><div class="fn"/><b><a href="qmenubar.html#dtor.QMenuBar">~QMenuBar</a></b> ()</li>
 
42
<li><div class="fn"/>QAction * <b><a href="qmenubar.html#activeAction">activeAction</a></b> () const</li>
 
43
<li><div class="fn"/>QAction * <b><a href="qmenubar.html#addAction">addAction</a></b> ( const QString &amp; <i>text</i> )</li>
 
44
<li><div class="fn"/>QAction * <b><a href="qmenubar.html#addAction-2">addAction</a></b> ( const QString &amp; <i>text</i>, const QObject * <i>receiver</i>, const char * <i>member</i> )</li>
 
45
<li><div class="fn"/>QAction * <b><a href="qmenubar.html#addMenu">addMenu</a></b> ( QMenu * <i>menu</i> )</li>
 
46
<li><div class="fn"/>QMenu * <b><a href="qmenubar.html#addMenu-2">addMenu</a></b> ( const QString &amp; <i>title</i> )</li>
 
47
<li><div class="fn"/>QMenu * <b><a href="qmenubar.html#addMenu-3">addMenu</a></b> ( const QIcon &amp; <i>icon</i>, const QString &amp; <i>title</i> )</li>
 
48
<li><div class="fn"/>QAction * <b><a href="qmenubar.html#addSeparator">addSeparator</a></b> ()</li>
 
49
<li><div class="fn"/>void <b><a href="qmenubar.html#clear">clear</a></b> ()</li>
 
50
<li><div class="fn"/>QAction * <b><a href="qmenubar.html#insertMenu">insertMenu</a></b> ( QAction * <i>before</i>, QMenu * <i>menu</i> )</li>
 
51
<li><div class="fn"/>bool <b><a href="qmenubar.html#defaultUp-prop">isDefaultUp</a></b> () const</li>
 
52
<li><div class="fn"/>void <b><a href="qmenubar.html#defaultUp-prop">setDefaultUp</a></b> ( bool )</li>
 
53
</ul>
 
54
<ul>
 
55
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
 
56
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
57
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
 
58
</ul>
 
59
<a name="signals"></a>
 
60
<h3>Signals</h3>
 
61
<ul>
 
62
<li><div class="fn"/>void <b><a href="qmenubar.html#hovered">hovered</a></b> ( QAction * <i>action</i> )</li>
 
63
<li><div class="fn"/>void <b><a href="qmenubar.html#triggered">triggered</a></b> ( QAction * <i>action</i> )</li>
 
64
</ul>
 
65
<ul>
 
66
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
 
67
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
68
</ul>
 
69
<h3>Additional Inherited Members</h3>
 
70
<ul>
 
71
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
 
72
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
73
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
 
74
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
75
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
 
76
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
77
</ul>
 
78
<a name="details"></a>
 
79
<hr />
 
80
<h2>Detailed Description</h2>
 
81
<p>The QMenuBar class provides a horizontal menu bar.</p>
 
82
<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>
 
83
<pre>&nbsp;   menubar-&gt;addMenu(fileMenu);</pre>
 
84
<p>The ampersand in the menu item's text sets Alt+F as a shortcut for this menu. (You can use &quot;&amp;&amp;&quot; to get a real ampersand in the menu bar.)</p>
 
85
<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>
 
86
<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>
 
87
<p>Example (from the <a href="mainwindows-menus.html">Menus</a> example):</p>
 
88
<pre>&nbsp;       fileMenu = menuBar()-&gt;addMenu(tr(&quot;&amp;File&quot;));
 
89
        fileMenu-&gt;addAction(newAct);</pre>
 
90
<p>Menu items may be removed with <a href="qwidget.html#removeAction">removeAction</a>().</p>
 
91
<p><img src="images/qmenubar-m.png" alt="Screenshot in Motif style" /> <img src="images/qmenubar-w.png" alt="Screenshot in Windows style" /></p>
 
92
<a name="qmenubar-on-qt-mac"></a>
 
93
<h3>QMenuBar on Qt/Mac</h3>
 
94
<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>
 
95
<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 &quot;QMenuBar&quot; 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>
 
96
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
97
<tr valign="top" bgcolor="#a2c511"><th>String matches</th><th>Placement</th><th>Notes</th></tr>
 
98
<tr valign="top" bgcolor="#f0f0f0"><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>
 
99
<tr valign="top" bgcolor="#e0e0e0"><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>
 
100
<tr valign="top" bgcolor="#f0f0f0"><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>
 
101
</table>
 
102
<p>The <a href="mainwindows-menus.html">Menus</a> example shows how to use QMenuBar and <a href="qmenu.html">QMenu</a>.</p>
 
103
<p>See also <a href="qmenu.html">QMenu</a>, <a href="qshortcut.html">QShortcut</a>, <a href="qaction.html">QAction</a>, <a href="http://developer.apple.com/techpubs/macosx/Carbon/HumanInterfaceToolbox/Aqua/aqua.html">Aqua Style Guidelines</a>, and <a href="guibooks.html#fowler">GUI Design Handbook: Menu Bar</a>.</p>
 
104
<hr />
 
105
<h2>Property Documentation</h2>
 
106
<h3 class="fn"><a name="defaultUp-prop"></a>defaultUp : bool</h3>
 
107
<p>This property holds the popup orientation.</p>
 
108
<p>The default popup orientation. By default, menus pop &quot;down&quot; the screen. By setting the property to true, the menu will pop &quot;up&quot;. You might call this for menus that are <i>below</i> the document to which they refer.</p>
 
109
<p>If the menu would not fit on the screen, the other direction is used automatically.</p>
 
110
<p>Access functions:</p>
 
111
<ul>
 
112
<li><div class="fn"/><b>bool isDefaultUp () const</b></li>
 
113
<li><div class="fn"/><b>void setDefaultUp ( bool )</b></li>
 
114
</ul>
 
115
<hr />
 
116
<h2>Member Function Documentation</h2>
 
117
<h3 class="fn"><a name="QMenuBar"></a>QMenuBar::QMenuBar ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
 
118
<p>Constructs a menu bar with parent <i>parent</i>.</p>
 
119
<h3 class="fn"><a name="dtor.QMenuBar"></a>QMenuBar::~QMenuBar ()</h3>
 
120
<p>Destroys the menu bar.</p>
 
121
<h3 class="fn"><a name="activeAction"></a><a href="qaction.html">QAction</a> * QMenuBar::activeAction () const</h3>
 
122
<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>
 
123
<h3 class="fn"><a name="addAction"></a><a href="qaction.html">QAction</a> * QMenuBar::addAction ( const <a href="qstring.html">QString</a> &amp; <i>text</i> )</h3>
 
124
<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>
 
125
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
 
126
<h3 class="fn"><a name="addAction-2"></a><a href="qaction.html">QAction</a> * QMenuBar::addAction ( const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qobject.html">QObject</a> * <i>receiver</i>, const char * <i>member</i> )</h3>
 
127
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
128
<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>
 
129
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>().</p>
 
130
<h3 class="fn"><a name="addMenu"></a><a href="qaction.html">QAction</a> * QMenuBar::addMenu ( <a href="qmenu.html">QMenu</a> * <i>menu</i> )</h3>
 
131
<p>Appends <i>menu</i> to the menubar. Returns the menu's menuAction().</p>
 
132
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
 
133
<h3 class="fn"><a name="addMenu-2"></a><a href="qmenu.html">QMenu</a> * QMenuBar::addMenu ( const <a href="qstring.html">QString</a> &amp; <i>title</i> )</h3>
 
134
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
135
<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>
 
136
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
 
137
<h3 class="fn"><a name="addMenu-3"></a><a href="qmenu.html">QMenu</a> * QMenuBar::addMenu ( const <a href="qicon.html">QIcon</a> &amp; <i>icon</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i> )</h3>
 
138
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
139
<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>
 
140
<p>See also <a href="qwidget.html#addAction">QWidget::addAction</a>() and <a href="qmenu.html#menuAction">QMenu::menuAction</a>().</p>
 
141
<h3 class="fn"><a name="addSeparator"></a><a href="qaction.html">QAction</a> * QMenuBar::addSeparator ()</h3>
 
142
<p>Appends a separator to the menu.</p>
 
143
<h3 class="fn"><a name="clear"></a>void QMenuBar::clear ()</h3>
 
144
<p>Removes all the actions from the menu bar.</p>
 
145
<p>See also <a href="qwidget.html#removeAction">removeAction</a>().</p>
 
146
<h3 class="fn"><a name="hovered"></a>void QMenuBar::hovered ( <a href="qaction.html">QAction</a> * <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
147
<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>
 
148
<p>Often this is used to update status information.</p>
 
149
<p>See also <a href="qmenubar.html#triggered">triggered</a>() and <a href="qaction.html#hovered">QAction::hovered</a>().</p>
 
150
<h3 class="fn"><a name="insertMenu"></a><a href="qaction.html">QAction</a> * QMenuBar::insertMenu ( <a href="qaction.html">QAction</a> * <i>before</i>, <a href="qmenu.html">QMenu</a> * <i>menu</i> )</h3>
 
151
<p>This convenience function inserts <i>menu</i> before action <i>before</i> and returns the menus menuAction().</p>
 
152
<p>See also <a href="qwidget.html#insertAction">QWidget::insertAction</a>() and <a href="qmenubar.html#addMenu">addMenu</a>().</p>
 
153
<h3 class="fn"><a name="triggered"></a>void QMenuBar::triggered ( <a href="qaction.html">QAction</a> * <i>action</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
154
<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>
 
155
<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>
 
156
<p>See also <a href="qmenubar.html#hovered">hovered</a>() and <a href="qaction.html#triggered">QAction::triggered</a>().</p>
 
157
<p /><address><hr /><div align="center">
 
158
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
159
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
160
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
161
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
162
</tr></table></div></address></body>
 
163
</html>