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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QCustomMenuItem Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QCustomMenuItem Class Reference</h1><br clear="all">
<p>
The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qmenudata-h.html">qmenudata.h</a>></code>
<p>
Inherits <a href="qt.html">Qt</a>.
<p><a href="qcustommenuitem-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#ea288d"><b>QCustomMenuItem</b></a>()</div>
<li><div class="fn">virtual<a href="#e0f44b"><b>~QCustomMenuItem</b></a>()</div>
<li><div class="fn">virtualbool<a href="#aec451"><b>fullSpan</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#a4fc2b"><b>isSeparator</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#ee5105"><b>setFont</b></a>(constQFont&font)</div>
<li><div class="fn">virtualvoid<a href="#1e93ac"><b>paint</b></a>(QPainter*p, constQColorGroup&cg, boolact, boolenabled, intx, inty, intw, inth)</div>
<li><div class="fn">virtualQSize<a href="#3cce08"><b>sizeHint</b></a>()</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.
<p>
A custom menu item is a menu item that is defined by two purely
virtual functions, <a href="#1e93ac">paint</a>() and <a href="#3cce08">sizeHint</a>(). The size hint tells the
menu how much space it needs to reserve for this item, whereas paint
is called whenever the item needs painting.
<p>This simply mechanism gives applications the possibility to create
all kinds of application specific menu items. Examples are items
showing different fonts in a word processor, or menus that allow the
selection of drawing utilities in a vector drawing program.
<p>A custom item is inserted into a popup menu with
<a href="qmenudata.html#0076cb">QPopupMenu::insertItem</a>().
<p>Per default, a custom item can also have an icon set and/or an
accelerator key. You can, however, reimplement <a href="#aec451">fullSpan</a>() to return
TRUE if you want the item to span the entire popup menu width. This
is in particular useful for labels.
<p>If you want the custom item to be treated as a separator only,
reimplement <a href="#a4fc2b">isSeparator</a>() to return TRUE.
<p>Note that you can also insert pixmaps or bitmaps as items into a
popup menu. A custom menu item, however, offers even more
flexibility and - which is especially important under windows style
- the possibility to draw the item with a different color when it is
highlighted.
<p><a href="menu-menu-cpp.html">menu/menu.cpp</a> shows a simply example how custom menu items can be
used.
<p><img src=qpopmenu-fancy.png>
<p>See also <a href="qmenudata.html">QMenuData</a> and <a href="qpopupmenu.html">QPopupMenu</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="ea288d"></a>QCustomMenuItem::QCustomMenuItem()</h3>
<p>Constructs a QCustomMenuItem.
<h3 class="fn"><a name="e0f44b"></a>QCustomMenuItem::~QCustomMenuItem() <code>[virtual]</code></h3>
<p>Destructs a QCustomMenuItem.
<h3 class="fn">bool<a name="aec451"></a>QCustomMenuItem::fullSpan()const <code>[virtual]</code></h3>
<p>Returns whether this item wants to span the entire popup menu width.
The default is FALSE, meaning that the menu may show an icon and/or
an accelerator key for this item as well.
<h3 class="fn">bool<a name="a4fc2b"></a>QCustomMenuItem::isSeparator()const <code>[virtual]</code></h3>
<p>Returns whether this item is just a separator.
<h3 class="fn">void<a name="1e93ac"></a>QCustomMenuItem::paint(<a href="qpainter.html">QPainter</a>*p, const<a href="qcolorgroup.html">QColorGroup</a>&cg, boolact, boolenabled, intx, inty, intw, inth) <code>[virtual]</code></h3>
<p>Paints this item. When this function is invoked, the painter <em>p</em> is
set to the right font and the right foreground color suitable for a
menu item text. The item is active according to <em>act</em> and
enabled/disabled according to <em>enabled.</em> The geometry values <em>x, y, w</em> and h specify where to draw the item.
<p>Do not draw any background, this has already been done by the popup
menu according to the current gui style.
<h3 class="fn">void<a name="ee5105"></a>QCustomMenuItem::setFont(const<a href="qfont.html">QFont</a>&) <code>[virtual]</code></h3>
<p>Sets the font of the custom menu item.
<p>This function is called whenever the font in the popup menu
changes. For menu items that show their own individual font entry,
you want to ignore this.
<h3 class="fn"><a href="qsize.html">QSize</a><a name="3cce08"></a>QCustomMenuItem::sizeHint() <code>[virtual]</code></h3>
<p>Returns the size hint of this item.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|