1QCustomMenuItem(3qt) QCustomMenuItem(3qt)
2
3
4
6 QCustomMenuItem - Abstract base class for custom menu items in popup
7 menus
8
10 #include <qmenudata.h>
11
12 Inherits Qt.
13
14 Public Members
15 QCustomMenuItem ()
16 virtual ~QCustomMenuItem ()
17 virtual bool fullSpan () const
18 virtual bool isSeparator () const
19 virtual void setFont ( const QFont & font )
20 virtual void paint ( QPainter * p, const QColorGroup & cg, bool act,
21 bool enabled, int x, int y, int w, int h ) = 0
22 virtual QSize sizeHint () = 0
23
25 The QCustomMenuItem class is an abstract base class for custom menu
26 items in popup menus.
27
28 A custom menu item is a menu item that is defined by two pure virtual
29 functions, paint() and sizeHint(). The size hint tells the menu how
30 much space it needs to reserve for this item, and paint is called
31 whenever the item needs painting.
32
33 This simple mechanism allows you to create all kinds of application
34 specific menu items. Examples are items showing different fonts in a
35 word processor or menus that allow the selection of drawing utilities
36 in a vector drawing program.
37
38 A custom item is inserted into a popup menu with
39 QPopupMenu::insertItem().
40
41 By default, a custom item can also have an icon and a keyboard
42 accelerator. You can reimplement fullSpan() to return TRUE if you want
43 the item to span the entire popup menu width. This is particularly
44 useful for labels.
45
46 If you want the custom item to be treated just as a separator,
47 reimplement isSeparator() to return TRUE.
48
49 Note that you can insert pixmaps or bitmaps as items into a popup menu
50 without needing to create a QCustomMenuItem. However, custom menu items
51 offer more flexibility, and -- especially important with Windows style
52 -- provide the possibility of drawing the item with a different color
53 when it is highlighted.
54
55 menu/menu.cpp shows a simple example how custom menu items can be used.
56
57 Note: the current implementation of QCustomMenuItem will not recognize
58 shortcut keys that are from text with ampersands. Normal accelerators
59 work though.
60
61 [Image Omitted]
62
63 See also QMenuData, QPopupMenu, and Miscellaneous Classes.
64
67 Constructs a QCustomMenuItem
68
70 Destroys a QCustomMenuItem
71
73 Returns TRUE if this item wants to span the entire popup menu width;
74 otherwise returns FALSE. The default is FALSE, meaning that the menu
75 may show an icon and an accelerator key for this item as well.
76
78 Returns TRUE if this item is just a separator; otherwise returns FALSE.
79
81 bool enabled, int x, int y, int w, int h ) [pure virtual]