Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QStyleOptionMenuItem Class Reference

The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item. More...

    #include <QStyleOptionMenuItem>

Inherits QStyleOption.

- List of all members, including inherited members

### Public Types

- enum CheckType { NotCheckable, Exclusive, NonExclusive }
- enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, ..., EmptyArea }

### Read-Only Properties

checkType : CheckType checked : bool font : QFont icon : QIcon maxIconWidth : int | menuItemType : MenuItemType menuRect : QRect tabWidth : int text : QString

- 5 read-only properties inherited from QStyleOption

### Public Functions

- QStyleOptionMenuItem ()

- 1 public function inherited from QStyleOption

## Detailed Description

The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item.

The QStyleOptionMenuItem is used for drawing menu items from QMenu. It is also used for drawing other menu-related widgets.

## Member Type Documentation

### enum QStyleOptionMenuItem::CheckType

These enums are used to indicate whether or not a check mark should be drawn for the item, or even if it should be drawn at all.

`QStyleOptionMenuItem::NotCheckable` | The item is not checkable.
`QStyleOptionMenuItem::Exclusive` | The item is an exclusive check item (like a radio button).
`QStyleOptionMenuItem::NonExclusive` | The item is a non-exclusive check item (like a check box).

See also QAction::checkable, QAction::checked, and QActionGroup::exculsive.

### enum QStyleOptionMenuItem::MenuItemType

These values indicate the type of menu item that the structure describes.

`QStyleOptionMenuItem::Normal` | A normal menu item.
`QStyleOptionMenuItem::DefaultItem` | A menu item that is the default action
`QStyleOptionMenuItem::Separator` | A menu separator.
`QStyleOptionMenuItem::SubMenu` | Indicates the menu item points to a sub-menu.
`QStyleOptionMenuItem::Scroller` | A popup menu scroller (currently only used on Mac OS X).
`QStyleOptionMenuItem::TearOff` | A tear-off handle for the menu.
`QStyleOptionMenuItem::Margin` | The margin of the menu.
`QStyleOptionMenuItem::EmptyArea` | The empty area of the menu.

See also QMenu::defaultAction() and ..

## Property Documentation

### checkType : CheckType

This property holds the type of checkmark of the menu item.

See also CheckType.

### checked : bool

This property holds whether the menu item is checked or not.

### font : QFont

This property holds the font used for the menu item text.

This is the font that should be used for drawing the menu text minus the shortcut. The shortcut is usually drawn using the painter's font.

### icon : QIcon

This property holds the icon for the menu item.

### maxIconWidth : int

This property holds the maximum icon width for the icon in the menu item.

This can be used for drawing the icon into the correct place or properly aligning items. The variable must be set regardless of whether or not the menu item has an icon.

### menuItemType : MenuItemType

This property holds the type of menu item.

See also MenuItemType.

### menuRect : QRect

This property holds the rectangle for the entire menu.

### tabWidth : int

This property holds the tab width for the menu item.

The tab width is the distance between the text of the menu item and the shortcut.

### text : QString

This property holds the text for the menu item.

Note that the text format is something like this "Menu text\tShortcut".

If the menu item doesn't have a shortcut, it will just contain the menu item's text.

## Member Function Documentation

### QStyleOptionMenuItem::QStyleOptionMenuItem ()

Constructs a QStyleOptionMenuItem. The members variables are initialized to default values.