source: trunk/doc/html/qcustommenuitem.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 6.8 KB
RevLine 
[190]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmenudata.cpp:1461 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QCustomMenuItem Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCustomMenuItem Class Reference</h1>
33
34<p>The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qmenudata-h.html">qmenudata.h</a>&gt;</tt>
37<p>Inherits <a href="qt.html">Qt</a>.
38<p><a href="qcustommenuitem-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QCustomMenuItem"><b>QCustomMenuItem</b></a> ()</li>
42<li class=fn>virtual <a href="#~QCustomMenuItem"><b>~QCustomMenuItem</b></a> ()</li>
43<li class=fn>virtual bool <a href="#fullSpan"><b>fullSpan</b></a> () const</li>
44<li class=fn>virtual bool <a href="#isSeparator"><b>isSeparator</b></a> () const</li>
45<li class=fn>virtual void <a href="#setFont"><b>setFont</b></a> ( const&nbsp;QFont&nbsp;&amp;&nbsp;font )</li>
46<li class=fn>virtual void <a href="#paint"><b>paint</b></a> ( QPainter&nbsp;*&nbsp;p, const&nbsp;QColorGroup&nbsp;&amp;&nbsp;cg, bool&nbsp;act, bool&nbsp;enabled, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h ) = 0</li>
47<li class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</b></a> () = 0</li>
48</ul>
49<hr><a name="details"></a><h2>Detailed Description</h2>
50
51
52The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.
53<p>
54<p> A custom menu item is a menu item that is defined by two pure
55virtual functions, <a href="#paint">paint</a>() and <a href="#sizeHint">sizeHint</a>(). The size hint tells the
56menu how much space it needs to reserve for this item, and paint
57is called whenever the item needs painting.
58<p> This simple mechanism allows you to create all kinds of
59application specific menu items. Examples are items showing
60different fonts in a word processor or menus that allow the
61selection of drawing utilities in a vector drawing program.
62<p> A custom item is inserted into a popup menu with
63<a href="qmenudata.html#insertItem">QPopupMenu::insertItem</a>().
64<p> By default, a custom item can also have an icon and a keyboard
65accelerator. You can reimplement <a href="#fullSpan">fullSpan</a>() to return TRUE if you
66want the item to span the entire popup menu width. This is
67particularly useful for labels.
68<p> If you want the custom item to be treated just as a separator,
69reimplement <a href="#isSeparator">isSeparator</a>() to return TRUE.
70<p> Note that you can insert pixmaps or bitmaps as items into a popup
71menu without needing to create a QCustomMenuItem. However, custom
72menu items offer more flexibility, and -- especially important
73with Windows style -- provide the possibility of drawing the item
74with a different color when it is highlighted.
75<p> <a href="menu-example.html">menu/menu.cpp</a> shows a simple
76example how custom menu items can be used.
77<p> Note: the current implementation of QCustomMenuItem will not
78recognize shortcut keys that are from text with ampersands. Normal
79accelerators work though.
80<p> <img src=qpopmenu-fancy.png>
81<p> <p>See also <a href="qmenudata.html">QMenuData</a>, <a href="qpopupmenu.html">QPopupMenu</a>, and <a href="misc.html">Miscellaneous Classes</a>.
82
83<hr><h2>Member Function Documentation</h2>
84<h3 class=fn><a name="QCustomMenuItem"></a>QCustomMenuItem::QCustomMenuItem ()
85</h3>
86Constructs a QCustomMenuItem
87
88<h3 class=fn><a name="~QCustomMenuItem"></a>QCustomMenuItem::~QCustomMenuItem ()<tt> [virtual]</tt>
89</h3>
90Destroys a QCustomMenuItem
91
92<h3 class=fn>bool <a name="fullSpan"></a>QCustomMenuItem::fullSpan () const<tt> [virtual]</tt>
93</h3>
94Returns TRUE if this item wants to span the entire popup menu
95width; otherwise returns FALSE. The default is FALSE, meaning that
96the menu may show an icon and an accelerator key for this item as
97well.
98
99<h3 class=fn>bool <a name="isSeparator"></a>QCustomMenuItem::isSeparator () const<tt> [virtual]</tt>
100</h3>
101Returns TRUE if this item is just a separator; otherwise returns
102FALSE.
103
104<h3 class=fn>void <a name="paint"></a>QCustomMenuItem::paint ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, const&nbsp;<a href="qcolorgroup.html">QColorGroup</a>&nbsp;&amp;&nbsp;cg, bool&nbsp;act, bool&nbsp;enabled, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )<tt> [pure virtual]</tt>
105</h3>
106
107<p> Paints this item. When this function is invoked, the painter <em>p</em>
108is set to a font and foreground color suitable for a menu item
109text using color group <em>cg</em>. The item is active if <em>act</em> is TRUE
110and enabled if <em>enabled</em> is TRUE. The geometry values <em>x</em>, <em>y</em>,
111<em>w</em> and <em>h</em> specify where to draw the item.
112<p> Do not draw any background, this has already been done by the
113popup menu according to the current GUI style.
114
115<h3 class=fn>void <a name="setFont"></a>QCustomMenuItem::setFont ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;font )<tt> [virtual]</tt>
116</h3>
117Sets the font of the custom menu item to <em>font</em>.
118<p> This function is called whenever the font in the popup menu
119changes. For menu items that show their own individual font entry,
120you want to ignore this.
121
122<h3 class=fn><a href="qsize.html">QSize</a> <a name="sizeHint"></a>QCustomMenuItem::sizeHint ()<tt> [pure virtual]</tt>
123</h3>
124
125<p> Returns the item's size hint.
126
127<!-- eof -->
128<hr><p>
129This file is part of the <a href="index.html">Qt toolkit</a>.
130Copyright &copy; 1995-2007
131<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
132<table width=100% cellspacing=0 border=0><tr>
133<td>Copyright &copy; 2007
134<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
135<td align=right><div align=right>Qt 3.3.8</div>
136</table></div></address></body>
137</html>
Note: See TracBrowser for help on using the repository browser.