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
589
590
591
592
593
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmenubar.cpp:75 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQMenuBar Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQMenuBar Class Reference</h1>
<p>The TQMenuBar class provides a horizontal menu bar.
<a href="#details">More...</a>
<p><tt>#include <<a href="qmenubar-h.html">qmenubar.h</a>></tt>
<p>Inherits <a href="qframe.html">TQFrame</a> and <a href="qmenudata.html">TQMenuData</a>.
<p><a href="qmenubar-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQMenuBar"><b>TQMenuBar</b></a> ( TQWidget * parent = 0, const char * name = 0 )</li>
<li class=fn><a href="#~TQMenuBar"><b>~TQMenuBar</b></a> ()</li>
<li class=fn>virtual void <a href="#show"><b>show</b></a> ()</li>
<li class=fn>virtual void <a href="#hide"><b>hide</b></a> ()</li>
<li class=fn>virtual int <a href="#heightForWidth"><b>heightForWidth</b></a> ( int max_width ) const</li>
<li class=fn>enum <a href="#Separator-enum"><b>Separator</b></a> { Never = 0, InWindowsStyle = 1 }</li>
<li class=fn>Separator separator () const <em>(obsolete)</em></li>
<li class=fn>virtual void setSeparator ( Separator when ) <em>(obsolete)</em></li>
<li class=fn>void <a href="#setDefaultUp"><b>setDefaultUp</b></a> ( bool )</li>
<li class=fn>bool <a href="#isDefaultUp"><b>isDefaultUp</b></a> () const</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#activated"><b>activated</b></a> ( int id )</li>
<li class=fn>void <a href="#highlighted"><b>highlighted</b></a> ( int id )</li>
</ul>
<h2>Important Inherited Members</h2>
<ul>
<li class=fn>int <a href="#insertItem"><b>insertItem</b></a> ( const TQString & text, const TQObject * receiver, const char * member, const TQKeySequence & accel = 0, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-2"><b>insertItem</b></a> ( const TQIconSet & icon, const TQString & text, const TQObject * receiver, const char * member, const TQKeySequence & accel = 0, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-3"><b>insertItem</b></a> ( const TQPixmap & pixmap, const TQObject * receiver, const char * member, const TQKeySequence & accel = 0, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-4"><b>insertItem</b></a> ( const TQIconSet & icon, const TQPixmap & pixmap, const TQObject * receiver, const char * member, const TQKeySequence & accel = 0, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-5"><b>insertItem</b></a> ( const TQString & text, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-6"><b>insertItem</b></a> ( const TQIconSet & icon, const TQString & text, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-7"><b>insertItem</b></a> ( const TQString & text, TQPopupMenu * popup, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-8"><b>insertItem</b></a> ( const TQIconSet & icon, const TQString & text, TQPopupMenu * popup, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-9"><b>insertItem</b></a> ( const TQPixmap & pixmap, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-a"><b>insertItem</b></a> ( const TQIconSet & icon, const TQPixmap & pixmap, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-b"><b>insertItem</b></a> ( const TQPixmap & pixmap, TQPopupMenu * popup, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-c"><b>insertItem</b></a> ( const TQIconSet & icon, const TQPixmap & pixmap, TQPopupMenu * popup, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-d"><b>insertItem</b></a> ( TQWidget * widget, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-e"><b>insertItem</b></a> ( const TQIconSet & icon, TQCustomMenuItem * custom, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertItem-f"><b>insertItem</b></a> ( TQCustomMenuItem * custom, int id = -1, int index = -1 )</li>
<li class=fn>int <a href="#insertSeparator"><b>insertSeparator</b></a> ( int index = -1 )</li>
<li class=fn>void <a href="#removeItem"><b>removeItem</b></a> ( int id )</li>
<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
<li class=fn>bool <a href="#isItemEnabled"><b>isItemEnabled</b></a> ( int id ) const</li>
<li class=fn>void <a href="#setItemEnabled"><b>setItemEnabled</b></a> ( int id, bool enable )</li>
<li class=fn>bool <a href="#isItemVisible"><b>isItemVisible</b></a> ( int id ) const</li>
<li class=fn>void <a href="#setItemVisible"><b>setItemVisible</b></a> ( int id, bool visible )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>bool <a href="#defaultUp-prop"><b>defaultUp</b></a> - the popup orientation</li>
<li class=fn>Separator separator - in which cases a menubar sparator is drawn <em>(obsolete)</em></li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( TQPainter * p )</li>
<li class=fn>virtual void <a href="#menuContentsChanged"><b>menuContentsChanged</b></a> ()</li>
<li class=fn>virtual void <a href="#menuStateChanged"><b>menuStateChanged</b></a> ()</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQMenuBar 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="qmenudata.html#insertItem">insertItem()</a>. For example, asuming that <tt>menubar</tt> is a
pointer to a TQMenuBar and <tt>filemenu</tt> is a pointer to a
<a href="qpopupmenu.html">TQPopupMenu</a>, the following statement inserts the menu into the menu
bar:
<pre>
menubar->insertItem( "&File", filemenu );
</pre>
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.)
<p> Items are either enabled or disabled. You toggle their state with
<a href="qmenudata.html#setItemEnabled">setItemEnabled</a>().
<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> Example of creating a menu bar with menu items (from <a href="menu-example.html">menu/menu.cpp</a>):
<pre> <a href="qpopupmenu.html">TQPopupMenu</a> *file = new <a href="qpopupmenu.html">TQPopupMenu</a>( this );
</pre><pre> file-><a href="qmenudata.html#insertItem">insertItem</a>( p1, "&Open", this, SLOT(open()), CTRL+Key_O );
file-><a href="qmenudata.html#insertItem">insertItem</a>( p2, "&New", this, SLOT(news()), CTRL+Key_N );
</pre><pre> menu = new TQMenuBar( this );
</pre><pre> menu-><a href="qmenudata.html#insertItem">insertItem</a>( "&File", file );
</pre>
<p> In most main window style applications you would use the menuBar()
provided in <a href="qmainwindow.html">TQMainWindow</a>, adding <a href="qpopupmenu.html">TQPopupMenu</a>s to the menu bar
and adding <a href="qaction.html">TQAction</a>s to the popup menus.
<p> Example (from <a href="qaction-application-example.html">action/application.cpp</a>):
<pre> <a href="qpopupmenu.html">TQPopupMenu</a> * file = new <a href="qpopupmenu.html">TQPopupMenu</a>( this );
<a href="qmainwindow.html#menuBar">menuBar</a>()->insertItem( "&File", file );
fileNewAction-><a href="qaction.html#addTo">addTo</a>( file );
</pre>
<p> Menu items can have text and pixmaps (or iconsets), see the
various <a href="qmenudata.html#insertItem">insertItem()</a>
overloads, as well as separators, see <a href="qmenudata.html#insertSeparator">insertSeparator()</a>. You can
also add custom menu items that are derived from
<a href="qcustommenuitem.html">TQCustomMenuItem</a>.
<p> Menu items may be removed with <a href="qmenudata.html#removeItem">removeItem</a>() and enabled or
disabled with <a href="qmenudata.html#setItemEnabled">setItemEnabled()</a>.
<p> <img src=qmenubar-m.png> <img src=qmenubar-w.png>
<p> <h3> TQMenuBar on TQt/Mac
</h3>
<a name="1"></a><p> TQMenuBar on TQt/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 <a href="qt.html#WidgetFlags">widget flag</a> <a href="qt.html#WidgetFlags-enum">WType_TopLevel</a>) will
be used for the system-wide menubar.
<p> Note that arbitrary TQt widgets <em>cannot</em> be inserted into a
TQMenuBar on the Mac because TQt uses Mac's native menus which don't
support this functionality. This limitation does not apply to
stand-alone TQPopupMenus.
<p> TQt/Mac also provides a menubar merging feature to make TQMenuBar
conform more closely to accepted Mac OS X menubar layout. The
merging functionality is based on string matching the title of a
<a href="qpopupmenu.html">TQPopupMenu</a> entry. These strings are translated (using
<a href="qobject.html#tr">TQObject::tr</a>()) in the "TQMenuBar" 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> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">String matches <th valign="top">Placement <th valign="top">Notes
<tr bgcolor="#f0f0f0"> <td valign="top">about.*
<td valign="top">Application Menu | About <application name>
<td valign="top">If this entry is not found no About item will appear in
the Application Menu
<tr bgcolor="#d0d0d0"> <td valign="top">config, options, setup, settings or preferences
<td valign="top">Application Menu | Preferences
<td valign="top">If this entry is not found the Settings item will be disabled
<tr bgcolor="#f0f0f0"> <td valign="top">tquit or exit
<td valign="top">Application Menu | Quit <application name>
<td valign="top">If this entry is not found a default Quit item will be
created to call <a href="qapplication.html#tquit">TQApplication::tquit</a>()
</table></center>
<p> <a href="menu-example.html">menu/menu.cpp</a> is an example of
TQMenuBar and <a href="qpopupmenu.html">TQPopupMenu</a> use.
<p> <p>See also <a href="qpopupmenu.html">TQPopupMenu</a>, <a href="qaccel.html">TQAccel</a>, <a href="qaction.html">TQAction</a>, <a href="http://developer.apple.com/techpubs/macosx/Carbon/HumanInterfaceToolbox/Aqua/aqua.html">Aqua Style Guidelines</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Menu Bar</a>, and <a href="application.html">Main Window and Related Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Separator-enum"></a>TQMenuBar::Separator</h3>
<p> This enum type is used to decide whether TQMenuBar should draw a
separator line at its bottom.
<ul>
<li><tt>TQMenuBar::Never</tt> - In many applications there is already a separator,
and having two looks wrong.
<li><tt>TQMenuBar::InWindowsStyle</tt> - In some other applications a separator looks
good in Windows style, but nowhere else.
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQMenuBar"></a>TQMenuBar::TQMenuBar ( <a href="qwidget.html">TQWidget</a> * parent = 0, const char * name = 0 )
</h3>
Constructs a menu bar called <em>name</em> with parent <em>parent</em>.
<h3 class=fn><a name="~TQMenuBar"></a>TQMenuBar::~TQMenuBar ()
</h3>
Destroys the menu bar.
<h3 class=fn>void <a name="activated"></a>TQMenuBar::activated ( int id )<tt> [signal]</tt>
</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#insertItem">TQMenuData::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 useful in such cases.
<p> <p>See also <a href="#highlighted">highlighted</a>() and <a href="qmenudata.html#insertItem">TQMenuData::insertItem</a>().
<p>Example: <a href="progress-example.html#x67">progress/progress.cpp</a>.
<h3 class=fn>void <a name="clear"></a>TQMenuData::clear ()
</h3>
Removes all menu items.
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>() and <a href="qmenudata.html#removeItemAt">removeItemAt</a>().
<p>Examples: <a href="mdi-example.html#x2029">mdi/application.cpp</a> and <a href="qwerty-example.html#x370">qwerty/qwerty.cpp</a>.
<h3 class=fn>void <a name="drawContents"></a>TQMenuBar::drawContents ( <a href="qpainter.html">TQPainter</a> * p )<tt> [virtual protected]</tt>
</h3>
Called from <a href="qframe.html#paintEvent">TQFrame::paintEvent</a>(). Draws the menu bar contents
using painter <em>p</em>.
<p>Reimplemented from <a href="qframe.html#drawContents">TQFrame</a>.
<h3 class=fn>int <a name="heightForWidth"></a>TQMenuBar::heightForWidth ( int max_width ) const<tt> [virtual]</tt>
</h3>
Returns the height that the menu would resize itself to if its
parent (and hence itself) resized to the given <em>max_width</em>. This
can be useful for simple layout tasks in which the height of the
menu bar is needed after items have been inserted. See <a href="showimg-example.html">showimg/showimg.cpp</a> for an example of the usage.
<p>Example: <a href="showimg-example.html#x1325">showimg/showimg.cpp</a>.
<p>Reimplemented from <a href="qwidget.html#heightForWidth">TQWidget</a>.
<h3 class=fn>void <a name="hide"></a>TQMenuBar::hide ()<tt> [virtual]</tt>
</h3>
Reimplements <a href="qwidget.html#hide">TQWidget::hide</a>() in order to deselect any selected
item, and calls setUpLayout() for the main window.
<p>Example: <a href="grapher-nsplugin-example.html#x2745">grapher/grapher.cpp</a>.
<p>Reimplemented from <a href="qwidget.html#hide">TQWidget</a>.
<h3 class=fn>void <a name="highlighted"></a>TQMenuBar::highlighted ( int id )<tt> [signal]</tt>
</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#insertItem">TQMenuData::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 useful in such cases.
<p> <p>See also <a href="#activated">activated</a>() and <a href="qmenudata.html#insertItem">TQMenuData::insertItem</a>().
<h3 class=fn>int <a name="insertItem"></a>TQMenuData::insertItem ( const <a href="qstring.html">TQString</a> & text, const <a href="qobject.html">TQObject</a> * receiver, const char * member, const <a href="qkeysequence.html">TQKeySequence</a> & accel = 0, int id = -1, int index = -1 )
</h3>
The family of <a href="qmenudata.html#insertItem">insertItem</a>() functions inserts menu items into a
popup menu or a menu bar.
<p> 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 <a href="qcustommenuitem.html">TQCustomMenuItem</a>) or
even widgets into popup menus.
<p> 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.
<p> The number of insert functions may look confusing, but they are
actually tquite simple to use.
<p> This default version inserts a menu item with the text <em>text</em>,
the accelerator key <em>accel</em>, an id and an optional index and
connects it to the slot <em>member</em> in the object <em>receiver</em>.
<p> Example:
<pre>
TQMenuBar *mainMenu = new TQMenuBar;
<a href="qpopupmenu.html">TQPopupMenu</a> *fileMenu = new <a href="qpopupmenu.html">TQPopupMenu</a>;
fileMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "New", myView, SLOT(newFile()), CTRL+Key_N );
fileMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "Open", myView, SLOT(open()), CTRL+Key_O );
mainMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "File", fileMenu );
</pre>
<p> Not all insert functions take an object/slot parameter or an
accelerator key. Use <a href="qmenudata.html#connectItem">connectItem</a>() and <a href="qmenudata.html#setAccel">setAccel</a>() on those items.
<p> If you need to translate accelerators, use <a href="qobject.html#tr">tr</a>() with the text and
accelerator. (For translations use a string <a href="qkeysequence.html">key
sequence</a>.):
<pre>
fileMenu->insertItem( <a href="qobject.html#tr">tr</a>("Open"), myView, SLOT(open()),
<a href="qobject.html#tr">tr</a>("Ctrl+O") );
</pre>
<p> In the example above, pressing Ctrl+O or selecting "Open" from the
menu activates the myView->open() function.
<p> Some insert functions take a <a href="qiconset.html">TQIconSet</a> parameter to specify the
little menu item icon. Note that you can always pass a <a href="qpixmap.html">TQPixmap</a>
object instead.
<p> The <em>id</em> specifies the identification number associated with the
menu item. Note that only positive values are valid, as a negative
value will make TQt select a unique id for the item.
<p> The <em>index</em> specifies the position in the menu. The menu item is
appended at the end of the list if <em>index</em> is negative.
<p> Note that keyboard accelerators in TQt are not application-global,
instead they are bound to a certain top-level window. For example,
accelerators in <a href="qpopupmenu.html">TQPopupMenu</a> 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 <a href="qwidget.html#parentWidget">parentWidget</a>()
chain. The menu will then install its accelerator object on that
top-level widget. For all other cases use an independent <a href="qaccel.html">TQAccel</a>
object.
<p> <b>Warning:</b> Be careful when passing a literal 0 to <a href="qmenudata.html#insertItem">insertItem</a>()
because some C++ compilers choose the wrong overloaded function.
Cast the 0 to what you mean, e.g. <tt>(TQObject*)0</tt>.
<p> <b>Warning:</b> 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 TQt
version.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qaccel.html">TQAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
<p>Examples: <a href="addressbook-example.html#x569">addressbook/mainwindow.cpp</a>, <a href="canvas-example.html#x2936">canvas/canvas.cpp</a>, <a href="menu-example.html#x1869">menu/menu.cpp</a>, <a href="qwerty-example.html#x371">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x634">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x1327">showimg/showimg.cpp</a>, and <a href="sound-example.html#x2810">sound/sound.cpp</a>.
<h3 class=fn>int <a name="insertItem-2"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, const <a href="qstring.html">TQString</a> & text, const <a href="qobject.html">TQObject</a> * receiver, const char * member, const <a href="qkeysequence.html">TQKeySequence</a> & accel = 0, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, accelerator
<em>accel</em>, optional id <em>id</em>, and optional <em>index</em> position. The
menu item is connected it to the <em>receiver</em>'s <em>member</em> slot. The
icon will be displayed to the left of the text in the item.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qaccel.html">TQAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
<h3 class=fn>int <a name="insertItem-3"></a>TQMenuData::insertItem ( const <a href="qpixmap.html">TQPixmap</a> & pixmap, const <a href="qobject.html">TQObject</a> * receiver, const char * member, const <a href="qkeysequence.html">TQKeySequence</a> & accel = 0, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with pixmap <em>pixmap</em>, accelerator <em>accel</em>,
optional id <em>id</em>, and optional <em>index</em> position. The menu item
is connected it to the <em>receiver</em>'s <em>member</em> slot. The icon will
be displayed to the left of the text in the item.
<p> To look best when being highlighted as a menu item, the pixmap
should provide a mask (see <a href="qpixmap.html#mask">TQPixmap::mask</a>()).
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-4"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, const <a href="qpixmap.html">TQPixmap</a> & pixmap, const <a href="qobject.html">TQObject</a> * receiver, const char * member, const <a href="qkeysequence.html">TQKeySequence</a> & accel = 0, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>,
accelerator <em>accel</em>, optional id <em>id</em>, and optional <em>index</em>
position. The icon will be displayed to the left of the pixmap in
the item. The item is connected to the <em>member</em> slot in the <em>receiver</em> object.
<p> To look best when being highlighted as a menu item, the pixmap
should provide a mask (see <a href="qpixmap.html#mask">TQPixmap::mask</a>()).
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qaccel.html">TQAccel</a>, and <a href="qnamespace-h.html">qnamespace.h</a>.
<h3 class=fn>int <a name="insertItem-5"></a>TQMenuData::insertItem ( const <a href="qstring.html">TQString</a> & text, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with text <em>text</em>, optional id <em>id</em>, and
optional <em>index</em> position.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-6"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, const <a href="qstring.html">TQString</a> & text, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, optional id
<em>id</em>, and optional <em>index</em> position. The icon will be displayed
to the left of the text in the item.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-7"></a>TQMenuData::insertItem ( const <a href="qstring.html">TQString</a> & text, <a href="qpopupmenu.html">TQPopupMenu</a> * popup, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with text <em>text</em>, submenu <em>popup</em>, optional
id <em>id</em>, and optional <em>index</em> position.
<p> The <em>popup</em> 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.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-8"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, const <a href="qstring.html">TQString</a> & text, <a href="qpopupmenu.html">TQPopupMenu</a> * popup, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em> position. The icon
will be displayed to the left of the text in the item.
<p> The <em>popup</em> 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.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-9"></a>TQMenuData::insertItem ( const <a href="qpixmap.html">TQPixmap</a> & pixmap, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with pixmap <em>pixmap</em>, optional id <em>id</em>, and
optional <em>index</em> position.
<p> To look best when being highlighted as a menu item, the pixmap
should provide a mask (see <a href="qpixmap.html#mask">TQPixmap::mask</a>()).
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-a"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, const <a href="qpixmap.html">TQPixmap</a> & pixmap, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>, optional
id <em>id</em>, and optional <em>index</em> position. The icon will be
displayed to the left of the pixmap in the item.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-b"></a>TQMenuData::insertItem ( const <a href="qpixmap.html">TQPixmap</a> & pixmap, <a href="qpopupmenu.html">TQPopupMenu</a> * popup, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with pixmap <em>pixmap</em>, submenu <em>popup</em>,
optional id <em>id</em>, and optional <em>index</em> position.
<p> The <em>popup</em> 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.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-c"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, const <a href="qpixmap.html">TQPixmap</a> & pixmap, <a href="qpopupmenu.html">TQPopupMenu</a> * popup, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em> submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em> position. The icon
will be displayed to the left of the pixmap in the item.
<p> The <em>popup</em> 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.
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>(), <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#setAccel">setAccel</a>(), and <a href="qmenudata.html#connectItem">connectItem</a>().
<h3 class=fn>int <a name="insertItem-d"></a>TQMenuData::insertItem ( <a href="qwidget.html">TQWidget</a> * widget, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a menu item that consists of the widget <em>widget</em> with
optional id <em>id</em>, and optional <em>index</em> position.
<p> Ownership of <em>widget</em> is transferred to the popup menu or to the
menu bar.
<p> Theoretically, any widget can be inserted into a popup menu. In
practice, this only makes sense with certain widgets.
<p> If a widget is not focus-enabled (see
<a href="qwidget.html#isFocusEnabled">TQWidget::isFocusEnabled</a>()), 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 <a href="qlabel.html">TQLabel</a> if
you need a popup menu with a title.
<p> 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 <tt>ArrowUp</tt> and <tt>ArrowDown</tt> 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 <a href="qlineedit.html">TQLineEdit</a>, 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
<a href="qwidget.html#focusNextPrevChild">TQWidget::focusNextPrevChild</a>(). Futhermore, if the embedded widget
closes the menu when the user made a selection, this can be done
safely by calling:
<pre>
if ( <a href="qwidget.html#isVisible">isVisible</a>() &&
<a href="qwidget.html#parentWidget">parentWidget</a>() &&
<a href="qwidget.html#parentWidget">parentWidget</a>()->inherits("TQPopupMenu") )
<a href="qwidget.html#parentWidget">parentWidget</a>()->close();
</pre>
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#removeItem">removeItem</a>().
<h3 class=fn>int <a name="insertItem-e"></a>TQMenuData::insertItem ( const <a href="qiconset.html">TQIconSet</a> & icon, <a href="qcustommenuitem.html">TQCustomMenuItem</a> * custom, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a custom menu item <em>custom</em> with an <em>icon</em> and with
optional id <em>id</em>, and optional <em>index</em> position.
<p> This only works with popup menus. It is not supported for menu
bars. Ownership of <em>custom</em> is transferred to the popup menu.
<p> If you want to connect a custom item to a slot, use <a href="qmenudata.html#connectItem">connectItem</a>().
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#removeItem">removeItem</a>(), and <a href="qcustommenuitem.html">TQCustomMenuItem</a>.
<h3 class=fn>int <a name="insertItem-f"></a>TQMenuData::insertItem ( <a href="qcustommenuitem.html">TQCustomMenuItem</a> * custom, int id = -1, int index = -1 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Inserts a custom menu item <em>custom</em> with optional id <em>id</em>, and
optional <em>index</em> position.
<p> This only works with popup menus. It is not supported for menu
bars. Ownership of <em>custom</em> is transferred to the popup menu.
<p> If you want to connect a custom item to a slot, use <a href="qmenudata.html#connectItem">connectItem</a>().
<p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0).
<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#removeItem">removeItem</a>(), and <a href="qcustommenuitem.html">TQCustomMenuItem</a>.
<h3 class=fn>int <a name="insertSeparator"></a>TQMenuData::insertSeparator ( int index = -1 )
</h3>
Inserts a separator at position <em>index</em>, and returns the <a href="qmenudata.html#menu-identifier">menu identifier</a>
number allocated to it. The separator becomes the last menu item if
<em>index</em> is negative.
<p> In a popup menu a separator is rendered as a horizontal line. In a
<a href="motif-extension.html#Motif">Motif</a> 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).
<p>Examples: <a href="addressbook-example.html#x570">addressbook/mainwindow.cpp</a>, <a href="menu-example.html#x1870">menu/menu.cpp</a>, <a href="progress-example.html#x69">progress/progress.cpp</a>, <a href="qwerty-example.html#x372">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x635">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x1328">showimg/showimg.cpp</a>, and <a href="sound-example.html#x2811">sound/sound.cpp</a>.
<h3 class=fn>bool <a name="isDefaultUp"></a>TQMenuBar::isDefaultUp () const
</h3><p>Returns the popup orientation.
See the <a href="qmenubar.html#defaultUp-prop">"defaultUp"</a> property for details.
<h3 class=fn>bool <a name="isItemEnabled"></a>TQMenuData::isItemEnabled ( int id ) const
</h3>
Returns TRUE if the item with identifier <em>id</em> is enabled;
otherwise returns FALSE
<p> <p>See also <a href="qmenudata.html#setItemEnabled">setItemEnabled</a>() and <a href="qmenudata.html#isItemVisible">isItemVisible</a>().
<h3 class=fn>bool <a name="isItemVisible"></a>TQMenuData::isItemVisible ( int id ) const
</h3>
Returns TRUE if the menu item with the id <em>id</em> is visible;
otherwise returns FALSE.
<p> <p>See also <a href="qmenudata.html#setItemVisible">setItemVisible</a>().
<h3 class=fn>void <a name="menuContentsChanged"></a>TQMenuBar::menuContentsChanged ()<tt> [virtual protected]</tt>
</h3>
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">TQMenuData</a> whenever it needs to be called.
<p>Reimplemented from <a href="qmenudata.html#menuContentsChanged">TQMenuData</a>.
<h3 class=fn>void <a name="menuStateChanged"></a>TQMenuBar::menuStateChanged ()<tt> [virtual protected]</tt>
</h3>
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">TQMenuData</a> whenever it needs to be called.
<p>Reimplemented from <a href="qmenudata.html#menuStateChanged">TQMenuData</a>.
<h3 class=fn>void <a name="removeItem"></a>TQMenuData::removeItem ( int id )
</h3>
<p> Removes the menu item that has the identifier <em>id</em>.
<p> <p>See also <a href="qmenudata.html#removeItemAt">removeItemAt</a>() and <a href="qmenudata.html#clear">clear</a>().
<p>Example: <a href="canvas-chart-example.html#x2885">chart/chartform.cpp</a>.
<h3 class=fn><a href="qmenubar.html#Separator-enum">Separator</a> <a name="separator"></a>TQMenuBar::separator () const
</h3><p>Returns in which cases a menubar sparator is drawn.
See the <a href="qmenubar.html#separator-prop">"separator"</a> property for details.
<h3 class=fn>void <a name="setDefaultUp"></a>TQMenuBar::setDefaultUp ( bool )
</h3><p>Sets the popup orientation.
See the <a href="qmenubar.html#defaultUp-prop">"defaultUp"</a> property for details.
<h3 class=fn>void <a name="setItemEnabled"></a>TQMenuData::setItemEnabled ( int id, bool enable )
</h3>
If <em>enable</em> is TRUE, enables the menu item with identifier <em>id</em>;
otherwise disables the menu item with identifier <em>id</em>.
<p> <p>See also <a href="qmenudata.html#isItemEnabled">isItemEnabled</a>().
<p>Examples: <a href="mdi-example.html#x2033">mdi/application.cpp</a>, <a href="menu-example.html#x1873">menu/menu.cpp</a>, <a href="progress-example.html#x72">progress/progress.cpp</a>, and <a href="showimg-example.html#x1331">showimg/showimg.cpp</a>.
<h3 class=fn>void <a name="setItemVisible"></a>TQMenuData::setItemVisible ( int id, bool visible )
</h3>
If <em>visible</em> is TRUE, shows the menu item with id <em>id</em>; otherwise
hides the menu item with id <em>id</em>.
<p> <p>See also <a href="qmenudata.html#isItemVisible">isItemVisible</a>() and <a href="qmenudata.html#isItemEnabled">isItemEnabled</a>().
<h3 class=fn>void <a name="setSeparator"></a>TQMenuBar::setSeparator ( <a href="qmenubar.html#Separator-enum">Separator</a> when )<tt> [virtual]</tt>
</h3><p>Sets in which cases a menubar sparator is drawn to <em>when</em>.
See the <a href="qmenubar.html#separator-prop">"separator"</a> property for details.
<h3 class=fn>void <a name="show"></a>TQMenuBar::show ()<tt> [virtual]</tt>
</h3>
Reimplements <a href="qwidget.html#show">TQWidget::show</a>() in order to set up the correct
keyboard accelerators and to raise itself to the top of the widget
stack.
<p>Example: <a href="grapher-nsplugin-example.html#x2746">grapher/grapher.cpp</a>.
<p>Reimplemented from <a href="qwidget.html#show">TQWidget</a>.
<hr><h2>Property Documentation</h2>
<h3 class=fn>bool <a name="defaultUp-prop"></a>defaultUp</h3>
<p>This property holds the popup orientation.
<p>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 <em>below</em> the document to
which they refer.
<p> If the menu would not fit on the screen, the other direction is
used automatically.
<p>Set this property's value with <a href="#setDefaultUp">setDefaultUp</a>() and get this property's value with <a href="#isDefaultUp">isDefaultUp</a>().
<h3 class=fn><a href="qmenubar.html#Separator-enum">Separator</a> <a name="separator-prop"></a>separator</h3>
<p>This property holds in which cases a menubar sparator is drawn.
<p><b>This property is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<p>Set this property's value with <a href="#setSeparator">setSeparator</a>() and get this property's value with <a href="#separator">separator</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 1995-2007
<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 © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|