summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qmenubar.3qt
blob: 9a4a2ec4cf56cdd605afb99368791c84d06b322e (plain)
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
'\" t
.TH QMenuBar 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QMenuBar \- Horizontal menu bar
.SH SYNOPSIS
\fC#include <ntqmenubar.h>\fR
.PP
Inherits QFrame and QMenuData.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQMenuBar\fR ( QWidget * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fB~QMenuBar\fR ()"
.br
.ti -1c
.BI "virtual void \fBshow\fR ()"
.br
.ti -1c
.BI "virtual void \fBhide\fR ()"
.br
.ti -1c
.BI "virtual int \fBheightForWidth\fR ( int max_width ) const"
.br
.ti -1c
.BI "enum \fBSeparator\fR { Never = 0, InWindowsStyle = 1 }"
.br
.ti -1c
.BI "Separator separator () const  \fI(obsolete)\fR"
.br
.ti -1c
.BI "virtual void setSeparator ( Separator when )  \fI(obsolete)\fR"
.br
.ti -1c
.BI "void \fBsetDefaultUp\fR ( bool )"
.br
.ti -1c
.BI "bool \fBisDefaultUp\fR () const"
.br
.in -1c
.SS "Signals"
.in +1c
.ti -1c
.BI "void \fBactivated\fR ( int id )"
.br
.ti -1c
.BI "void \fBhighlighted\fR ( int id )"
.br
.in -1c
.SS "Important Inherited Members"
.in +1c
.ti -1c
.BI "int \fBinsertItem\fR ( const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QString & text, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, const QString & text, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QString & text, QPopupMenu * popup, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, const QString & text, QPopupMenu * popup, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QPixmap & pixmap, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, const QPixmap & pixmap, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( QWidget * widget, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( const QIconSet & icon, QCustomMenuItem * custom, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertItem\fR ( QCustomMenuItem * custom, int id = -1, int index = -1 )"
.br
.ti -1c
.BI "int \fBinsertSeparator\fR ( int index = -1 )"
.br
.ti -1c
.BI "void \fBremoveItem\fR ( int id )"
.br
.ti -1c
.BI "void \fBclear\fR ()"
.br
.ti -1c
.BI "bool \fBisItemEnabled\fR ( int id ) const"
.br
.ti -1c
.BI "void \fBsetItemEnabled\fR ( int id, bool enable )"
.br
.ti -1c
.BI "bool \fBisItemVisible\fR ( int id ) const"
.br
.ti -1c
.BI "void \fBsetItemVisible\fR ( int id, bool visible )"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "bool \fBdefaultUp\fR - the popup orientation"
.br
.ti -1c
.BI "Separator separator - in which cases a menubar sparator is drawn  \fI(obsolete)\fR"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual void \fBdrawContents\fR ( QPainter * p )"
.br
.ti -1c
.BI "virtual void \fBmenuContentsChanged\fR ()"
.br
.ti -1c
.BI "virtual void \fBmenuStateChanged\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QMenuBar class provides a horizontal menu bar.
.PP
A menu bar consists of a list of pull-down menu items. You add menu items with insertItem(). For example, asuming that \fCmenubar\fR is a pointer to a QMenuBar and \fCfilemenu\fR is a pointer to a QPopupMenu, the following statement inserts the menu into the menu bar:
.PP
.nf
.br
    menubar->insertItem( "&File", filemenu );
.br
.fi
The ampersand in the menu item's text sets Alt+F as a shortcut for this menu. (You can use "&&" to get a real ampersand in the menu bar.)
.PP
Items are either enabled or disabled. You toggle their state with setItemEnabled().
.PP
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.
.PP
Example of creating a menu bar with menu items (from menu/menu.cpp):
.PP
.nf
.br
        QPopupMenu *file = new QPopupMenu( this );
.fi
.PP
.nf
.br
        file->insertItem( p1, "&Open",  this, SLOT(open()), CTRL+Key_O );
.br
        file->insertItem( p2, "&New", this, SLOT(news()), CTRL+Key_N );
.fi
.PP
.nf
.br
        menu = new QMenuBar( this );
.fi
.PP
.nf
.br
        menu->insertItem( "&File", file );
.fi
.PP
In most main window style applications you would use the menuBar() provided in QMainWindow, adding QPopupMenus to the menu bar and adding QActions to the popup menus.
.PP
Example (from action/application.cpp):
.PP
.nf
.br
        QPopupMenu * file = new QPopupMenu( this );
.br
        menuBar()->insertItem( "&File", file );
.br
        fileNewAction->addTo( file );
.fi
.PP
Menu items can have text and pixmaps (or iconsets), see the various insertItem() overloads, as well as separators, see insertSeparator(). You can also add custom menu items that are derived from QCustomMenuItem.
.PP
Menu items may be removed with removeItem() and enabled or disabled with setItemEnabled().
.PP
.ce 1
.B "[Image Omitted]"
.PP

.ce 1
.B "[Image Omitted]"
.PP
.SH "QMenuBar on Qt/Mac"
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 WType_TopLevel) will be used for the system-wide menubar.
.PP
Note that arbitrary Qt widgets \fIcannot\fR be inserted into a QMenuBar on the Mac because Qt uses Mac's native menus which don't support this functionality. This limitation does not apply to stand-alone QPopupMenus.
.PP
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 QPopupMenu entry. These strings are translated (using QObject::tr()) 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:
.PP
<center>.nf
.TS
l - l. String matches Placement Notes about.* Application Menu | About If this entry is not found no About item will appear in the Application Menu config, options, setup, settings or preferences Application Menu | Preferences If this entry is not found the Settings item will be disabled quit or exit Application Menu | Quit If this entry is not found a default Quit item will be created to call
.TE
.fi
</center>
.PP
menu/menu.cpp is an example of QMenuBar and QPopupMenu use.
.PP
See also QPopupMenu, QAccel, QAction, Aqua Style Guidelines, GUI Design Handbook: Menu Bar, and Main Window and Related Classes.
.SS "Member Type Documentation"
.SH "QMenuBar::Separator"
This enum type is used to decide whether QMenuBar should draw a separator line at its bottom.
.TP
\fCQMenuBar::Never\fR - In many applications there is already a separator, and having two looks wrong.
.TP
\fCQMenuBar::InWindowsStyle\fR - In some other applications a separator looks good in Windows style, but nowhere else.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QMenuBar::QMenuBar ( QWidget * parent = 0, const char * name = 0 )"
Constructs a menu bar called \fIname\fR with parent \fIparent\fR.
.SH "QMenuBar::~QMenuBar ()"
Destroys the menu bar.
.SH "void QMenuBar::activated ( int id )\fC [signal]\fR"
This signal is emitted when a menu item is selected; \fIid\fR is the id of the selected item.
.PP
Normally you will connect each menu item to a single slot using QMenuData::insertItem(), 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.
.PP
See also highlighted() and QMenuData::insertItem().
.PP
Example: progress/progress.cpp.
.SH "void QMenuData::clear ()"
Removes all menu items.
.PP
See also removeItem() and removeItemAt().
.PP
Examples:
.)l mdi/application.cpp and qwerty/qwerty.cpp.
.SH "void QMenuBar::drawContents ( QPainter * p )\fC [virtual protected]\fR"
Called from QFrame::paintEvent(). Draws the menu bar contents using painter \fIp\fR.
.PP
Reimplemented from QFrame.
.SH "int QMenuBar::heightForWidth ( int max_width ) const\fC [virtual]\fR"
Returns the height that the menu would resize itself to if its parent (and hence itself) resized to the given \fImax_width\fR. This can be useful for simple layout tasks in which the height of the menu bar is needed after items have been inserted. See showimg/showimg.cpp for an example of the usage.
.PP
Example: showimg/showimg.cpp.
.PP
Reimplemented from QWidget.
.SH "void QMenuBar::hide ()\fC [virtual]\fR"
Reimplements QWidget::hide() in order to deselect any selected item, and calls setUpLayout() for the main window.
.PP
Example: grapher/grapher.cpp.
.PP
Reimplemented from QWidget.
.SH "void QMenuBar::highlighted ( int id )\fC [signal]\fR"
This signal is emitted when a menu item is highlighted; \fIid\fR is the id of the highlighted item.
.PP
Normally, you will connect each menu item to a single slot using QMenuData::insertItem(), 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.
.PP
See also activated() and QMenuData::insertItem().
.SH "int QMenuData::insertItem ( const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
The family of insertItem() functions inserts menu items into a popup menu or a menu bar.
.PP
A menu item is usually either a text string or a pixmap, both with an optional icon or keyboard accelerator. For special cases it is also possible to insert custom items (see QCustomMenuItem) or even widgets into popup menus.
.PP
Some insertItem() members take a popup menu as an additional argument. Use this to insert submenus into existing menus or pulldown menus into a menu bar.
.PP
The number of insert functions may look confusing, but they are actually quite simple to use.
.PP
This default version inserts a menu item with the text \fItext\fR, the accelerator key \fIaccel\fR, an id and an optional index and connects it to the slot \fImember\fR in the object \fIreceiver\fR.
.PP
Example:
.PP
.nf
.br
        QMenuBar   *mainMenu = new QMenuBar;
.br
        QPopupMenu *fileMenu = new QPopupMenu;
.br
        fileMenu->insertItem( "New",  myView, SLOT(newFile()), CTRL+Key_N );
.br
        fileMenu->insertItem( "Open", myView, SLOT(open()),    CTRL+Key_O );
.br
        mainMenu->insertItem( "File", fileMenu );
.br
.fi
.PP
Not all insert functions take an object/slot parameter or an accelerator key. Use connectItem() and setAccel() on those items.
.PP
If you need to translate accelerators, use tr() with the text and accelerator. (For translations use a string key sequence.):
.PP
.nf
.br
        fileMenu->insertItem( tr("Open"), myView, SLOT(open()),
.br
                              tr("Ctrl+O") );
.br
.fi
.PP
In the example above, pressing Ctrl+O or selecting "Open" from the menu activates the myView->open() function.
.PP
Some insert functions take a QIconSet parameter to specify the little menu item icon. Note that you can always pass a QPixmap object instead.
.PP
The \fIid\fR specifies the identification number associated with the menu item. Note that only positive values are valid, as a negative value will make Qt select a unique id for the item.
.PP
The \fIindex\fR specifies the position in the menu. The menu item is appended at the end of the list if \fIindex\fR is negative.
.PP
Note that keyboard accelerators in Qt are not application-global, instead they are bound to a certain top-level window. For example, accelerators in QPopupMenu items only work for menus that are associated with a certain window. This is true for popup menus that live in a menu bar since their accelerators will then be installed in the menu bar itself. This also applies to stand-alone popup menus that have a top-level widget in their parentWidget() chain. The menu will then install its accelerator object on that top-level widget. For all other cases use an independent QAccel object.
.PP
\fBWarning:\fR Be careful when passing a literal 0 to insertItem() because some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, e.g. \fC(QObject*)0\fR.
.PP
\fBWarning:\fR On Mac OS X, items that connect to a slot that are inserted into a menubar will not function as we use the native menubar that knows nothing about signals or slots. Instead insert the items into a popup menu and insert the popup menu into the menubar. This may be fixed in a future Qt version.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), connectItem(), QAccel, and ntqnamespace.h.
.PP
Examples:
.)l addressbook/mainwindow.cpp, canvas/canvas.cpp, menu/menu.cpp, qwerty/qwerty.cpp, scrollview/scrollview.cpp, showimg/showimg.cpp, and sound/sound.cpp.
.SH "int QMenuData::insertItem ( const QIconSet & icon, const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with icon \fIicon\fR, text \fItext\fR, accelerator \fIaccel\fR, optional id \fIid\fR, and optional \fIindex\fR position. The menu item is connected it to the \fIreceiver\fR's \fImember\fR slot. The icon will be displayed to the left of the text in the item.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), connectItem(), QAccel, and ntqnamespace.h.
.SH "int QMenuData::insertItem ( const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with pixmap \fIpixmap\fR, accelerator \fIaccel\fR, optional id \fIid\fR, and optional \fIindex\fR position. The menu item is connected it to the \fIreceiver\fR's \fImember\fR slot. The icon will be displayed to the left of the text in the item.
.PP
To look best when being highlighted as a menu item, the pixmap should provide a mask (see QPixmap::mask()).
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QIconSet & icon, const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with icon \fIicon\fR, pixmap \fIpixmap\fR, accelerator \fIaccel\fR, optional id \fIid\fR, and optional \fIindex\fR position. The icon will be displayed to the left of the pixmap in the item. The item is connected to the \fImember\fR slot in the \fIreceiver\fR object.
.PP
To look best when being highlighted as a menu item, the pixmap should provide a mask (see QPixmap::mask()).
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), connectItem(), QAccel, and ntqnamespace.h.
.SH "int QMenuData::insertItem ( const QString & text, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with text \fItext\fR, optional id \fIid\fR, and optional \fIindex\fR position.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QIconSet & icon, const QString & text, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with icon \fIicon\fR, text \fItext\fR, optional id \fIid\fR, and optional \fIindex\fR position. The icon will be displayed to the left of the text in the item.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QString & text, QPopupMenu * popup, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with text \fItext\fR, submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR position.
.PP
The \fIpopup\fR must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QIconSet & icon, const QString & text, QPopupMenu * popup, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with icon \fIicon\fR, text \fItext\fR, submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR position. The icon will be displayed to the left of the text in the item.
.PP
The \fIpopup\fR must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QPixmap & pixmap, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with pixmap \fIpixmap\fR, optional id \fIid\fR, and optional \fIindex\fR position.
.PP
To look best when being highlighted as a menu item, the pixmap should provide a mask (see QPixmap::mask()).
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QIconSet & icon, const QPixmap & pixmap, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with icon \fIicon\fR, pixmap \fIpixmap\fR, optional id \fIid\fR, and optional \fIindex\fR position. The icon will be displayed to the left of the pixmap in the item.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with pixmap \fIpixmap\fR, submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR position.
.PP
The \fIpopup\fR must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( const QIconSet & icon, const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item with icon \fIicon\fR, pixmap \fIpixmap\fR submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR position. The icon will be displayed to the left of the pixmap in the item.
.PP
The \fIpopup\fR must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem(), changeItem(), setAccel(), and connectItem().
.SH "int QMenuData::insertItem ( QWidget * widget, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a menu item that consists of the widget \fIwidget\fR with optional id \fIid\fR, and optional \fIindex\fR position.
.PP
Ownership of \fIwidget\fR is transferred to the popup menu or to the menu bar.
.PP
Theoretically, any widget can be inserted into a popup menu. In practice, this only makes sense with certain widgets.
.PP
If a widget is not focus-enabled (see QWidget::isFocusEnabled()), the menu treats it as a separator; this means that the item is not selectable and will never get focus. In this way you can, for example, simply insert a QLabel if you need a popup menu with a title.
.PP
If the widget is focus-enabled it will get focus when the user traverses the popup menu with the arrow keys. If the widget does not accept \fCArrowUp\fR and \fCArrowDown\fR in its key event handler, the focus will move back to the menu when the respective arrow key is hit one more time. This works with a QLineEdit, for example. If the widget accepts the arrow key itself, it must also provide the possibility to put the focus back on the menu again by calling QWidget::focusNextPrevChild(). Futhermore, if the embedded widget closes the menu when the user made a selection, this can be done safely by calling:
.PP
.nf
.br
        if ( isVisible() &&
.br
             parentWidget() &&
.br
             parentWidget()->inherits("QPopupMenu") )
.br
            parentWidget()->close();
.br
.fi
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also removeItem().
.SH "int QMenuData::insertItem ( const QIconSet & icon, QCustomMenuItem * custom, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a custom menu item \fIcustom\fR with an \fIicon\fR and with optional id \fIid\fR, and optional \fIindex\fR position.
.PP
This only works with popup menus. It is not supported for menu bars. Ownership of \fIcustom\fR is transferred to the popup menu.
.PP
If you want to connect a custom item to a slot, use connectItem().
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also connectItem(), removeItem(), and QCustomMenuItem.
.SH "int QMenuData::insertItem ( QCustomMenuItem * custom, int id = -1, int index = -1 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Inserts a custom menu item \fIcustom\fR with optional id \fIid\fR, and optional \fIindex\fR position.
.PP
This only works with popup menus. It is not supported for menu bars. Ownership of \fIcustom\fR is transferred to the popup menu.
.PP
If you want to connect a custom item to a slot, use connectItem().
.PP
Returns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0).
.PP
See also connectItem(), removeItem(), and QCustomMenuItem.
.SH "int QMenuData::insertSeparator ( int index = -1 )"
Inserts a separator at position \fIindex\fR, and returns the menu identifier number allocated to it. The separator becomes the last menu item if \fIindex\fR is negative.
.PP
In a popup menu a separator is rendered as a horizontal line. In a Motif menu bar a separator is spacing, so the rest of the items (normally just "Help") are drawn right-justified. In a Windows menu bar separators are ignored (to comply with the Windows style guidelines).
.PP
Examples:
.)l addressbook/mainwindow.cpp, menu/menu.cpp, progress/progress.cpp, qwerty/qwerty.cpp, scrollview/scrollview.cpp, showimg/showimg.cpp, and sound/sound.cpp.
.SH "bool QMenuBar::isDefaultUp () const"
Returns the popup orientation. See the "defaultUp" property for details.
.SH "bool QMenuData::isItemEnabled ( int id ) const"
Returns TRUE if the item with identifier \fIid\fR is enabled; otherwise returns FALSE
.PP
See also setItemEnabled() and isItemVisible().
.SH "bool QMenuData::isItemVisible ( int id ) const"
Returns TRUE if the menu item with the id \fIid\fR is visible; otherwise returns FALSE.
.PP
See also setItemVisible().
.SH "void QMenuBar::menuContentsChanged ()\fC [virtual protected]\fR"
Recomputes the menu bar's display data according to the new contents.
.PP
You should never need to call this; it is called automatically by QMenuData whenever it needs to be called.
.PP
Reimplemented from QMenuData.
.SH "void QMenuBar::menuStateChanged ()\fC [virtual protected]\fR"
Recomputes the menu bar's display data according to the new state.
.PP
You should never need to call this; it is called automatically by QMenuData whenever it needs to be called.
.PP
Reimplemented from QMenuData.
.SH "void QMenuData::removeItem ( int id )"
Removes the menu item that has the identifier \fIid\fR.
.PP
See also removeItemAt() and clear().
.PP
Example: chart/chartform.cpp.
.SH "Separator QMenuBar::separator () const"
Returns in which cases a menubar sparator is drawn. See the "separator" property for details.
.SH "void QMenuBar::setDefaultUp ( bool )"
Sets the popup orientation. See the "defaultUp" property for details.
.SH "void QMenuData::setItemEnabled ( int id, bool enable )"
If \fIenable\fR is TRUE, enables the menu item with identifier \fIid\fR; otherwise disables the menu item with identifier \fIid\fR.
.PP
See also isItemEnabled().
.PP
Examples:
.)l mdi/application.cpp, menu/menu.cpp, progress/progress.cpp, and showimg/showimg.cpp.
.SH "void QMenuData::setItemVisible ( int id, bool visible )"
If \fIvisible\fR is TRUE, shows the menu item with id \fIid\fR; otherwise hides the menu item with id \fIid\fR.
.PP
See also isItemVisible() and isItemEnabled().
.SH "void QMenuBar::setSeparator ( Separator when )\fC [virtual]\fR"
Sets in which cases a menubar sparator is drawn to \fIwhen\fR. See the "separator" property for details.
.SH "void QMenuBar::show ()\fC [virtual]\fR"
Reimplements QWidget::show() in order to set up the correct keyboard accelerators and to raise itself to the top of the widget stack.
.PP
Example: grapher/grapher.cpp.
.PP
Reimplemented from QWidget.
.SS "Property Documentation"
.SH "bool defaultUp"
This property holds the popup orientation.
.PP
The default popup orientation. By default, menus pop "down" the screen. By setting the property to TRUE, the menu will pop "up". You might call this for menus that are \fIbelow\fR the document to which they refer.
.PP
If the menu would not fit on the screen, the other direction is used automatically.
.PP
Set this property's value with setDefaultUp() and get this property's value with isDefaultUp().
.SH "Separator separator"
This property holds in which cases a menubar sparator is drawn.
.PP
\fBThis property is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Set this property's value with setSeparator() and get this property's value with separator().

.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqmenubar.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qmenubar.3qt) and the Qt
version (3.3.8).