QCustomMenuItem(3qt)

NAME
QCustomMenuItem - Abstract base class for custom menu items in popup menus

SYNOPSIS

#include <qmenudata.h>

Inherits Qt.

  Public Members
QCustomMenuItem ()
virtual ~QCustomMenuItem ()
virtual bool fullSpan () const
virtual bool isSeparator () const
virtual void setFont ( const QFont & font )
virtual void paint ( QPainter * p, const QColorGroup & cg, bool act, bool enabled, int x, int y, int w, int h )
virtual QSize sizeHint ()

DESCRIPTION
The QCustomMenuItem class is an abstract base class for custom menu items in popup menus.

A custom menu item is a menu item that is defined by two purely virtual functions, paint() and sizeHint(). 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.

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.

A custom item is inserted into a popup menu with QPopupMenu::insertItem().

Per default, a custom item can also have an icon set and/or an accelerator key. You can, however, reimplement fullSpan() to return TRUE if you want the item to span the entire popup menu width. This is in particular useful for labels.

If you want the custom item to be treated as a separator only, reimplement isSeparator() to return TRUE.

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.

menu/menu.cpp shows a simply example how custom menu items can be used.

<img src=qpopmenu-fancy.png>

See also QMenuData and QPopupMenu.

MEMBER FUNCTION DOCUMENTATION

QCustomMenuItem::QCustomMenuItem ()
Constructs a QCustomMenuItem.

QCustomMenuItem::~QCustomMenuItem () [virtual]
Destructs a QCustomMenuItem.

bool QCustomMenuItem::fullSpan () const [virtual]
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.

bool QCustomMenuItem::isSeparator () const [virtual]
Returns whether this item is just a separator.

void QCustomMenuItem::paint ( QPainter * p, const QColorGroup & cg, bool act, bool enabled, int x, int y, int w, int h ) [virtual]
Paints this item. When this function is invoked, the painter p is set to the right font and the right foreground color suitable for a menu item text. The item is active according to act and enabled/disabled according to enabled. The geometry values x, y, w and h specify where to draw the item.

Do not draw any background, this has already been done by the popup menu according to the current gui style.

void QCustomMenuItem::setFont ( const QFont & ) [virtual]
Sets the font of the custom menu item.

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.

QSize QCustomMenuItem::sizeHint () [virtual]
Returns the size hint of this item.

SEE ALSO
http://doc.trolltech.com/qcustommenuitem.html

COPYRIGHT
Copyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.