CopperSpice API  1.8.1
QStyleOptionMenuItem Class Reference

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

Inheritance diagram for QStyleOptionMenuItem:
QStyleOption

Public Types

enum  CheckType
 
enum  MenuItemType
 
enum  StyleOptionType
 
enum  StyleOptionVersion
 
- Public Types inherited from QStyleOption
enum  OptionType
 
enum  StyleOptionType
 
enum  StyleOptionVersion
 

Public Methods

 QStyleOptionMenuItem ()
 
 QStyleOptionMenuItem (const QStyleOptionMenuItem &other)
 
QStyleOptionMenuItem & operator= (const QStyleOptionMenuItem &other) = default
 
- Public Methods inherited from QStyleOption
 QStyleOption (const QStyleOption &other)
 
 QStyleOption (int version=QStyleOption::Version, int type=SO_Default)
 
 ~QStyleOption ()
 
void initFrom (const QWidget *widget)
 
QStyleOption & operator= (const QStyleOption &other)
 

Public Members

bool checked
 
CheckType checkType
 
QFont font
 
QIcon icon
 
int maxIconWidth
 
bool menuHasCheckableItems
 
MenuItemType menuItemType
 
QRect menuRect
 
QString text
 
- Public Members inherited from QStyleOption
int type
 
int version
 

Additional Inherited Members

Detailed Description

The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item. QStyleOptionMenuItem contains all the information that QStyle functions need to draw the menu items from QMenu. It is also used for drawing other menu-related widgets.

See also
QStyleOption

Member Enumeration Documentation

This enum is used to indicate whether or not a check mark should be drawn for the item or if it should be drawn at all.

ConstantValueDescription
QStyleOptionMenuItem::NotCheckable0 The item is not checkable.
QStyleOptionMenuItem::Exclusive1 The item is an exclusive check item (like a radio button).
QStyleOptionMenuItem::NonExclusive2 The item is a non-exclusive check item (like a check box).
See also
QAction::checkable, QAction::checked, QActionGroup::exclusive, checkType

This enum indicates the type of menu item that the structure describes.

ConstantValueDescription
QStyleOptionMenuItem::Normal0 A normal menu item.
QStyleOptionMenuItem::DefaultItem1 A menu item that is the default action as specified with QMenu::defaultAction().
QStyleOptionMenuItem::Separator2 A menu separator.
QStyleOptionMenuItem::SubMenu3 Indicates the menu item points to a sub-menu.
QStyleOptionMenuItem::Scroller4 A popup menu scroller (currently only used on Mac OS X).
QStyleOptionMenuItem::TearOff5 A tear-off handle for the menu.
QStyleOptionMenuItem::Margin6 The margin of the menu.
QStyleOptionMenuItem::EmptyArea7 The empty area of the menu.
See also
menuItemType

This enum is used to hold information about the type of the style option, and is defined for each QStyleOption subclass.

The type is used internally by QStyleOption, subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles.

ConstantValueDescription
QStyleOptionMenuItem::TypeSO_MenuItem The type of style option provided (SO_MenuItem for this class).
See also
StyleOptionVersion

This enum is used to hold information about the version of the style option, and is defined for each QStyleOption subclass.

The version is used by QStyleOption subclasses to implement extensions without breaking compatibility. If you use qstyleoption_cast() you normally do not need to check it.

ConstantValueDescription
QStyleOptionMenuItem::Version11
See also
StyleOptionType

Constructor & Destructor Documentation

QStyleOptionMenuItem::QStyleOptionMenuItem ( )

Constructs an empty QStyleOptionMenuItem.

QStyleOptionMenuItem::QStyleOptionMenuItem ( const QStyleOptionMenuItem &  other)
inline

Copy constructs a new QStyleOptionMenuItem from other.

Method Documentation

QStyleOptionMenuItem & QStyleOptionMenuItem::operator= ( const QStyleOptionMenuItem &  other)
default

Copy assigns from other and returns a reference to this object.

Member Data Documentation

bool QStyleOptionMenuItem::checked

This variable holds whether the menu item is checked or not. The default value is false.

QStyleOptionMenuItem::CheckType QStyleOptionMenuItem::checkType

This variable holds the type of checkmark of the menu item. The default value is QStyleOptionMenuItem::NotCheckable.

See also
CheckType
QFont QStyleOptionMenuItem::font

This variable 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. By default the application default font is used.

QIcon QStyleOptionMenuItem::icon

This variable contains the icon for the menu item. The default value is an empty icon.

int QStyleOptionMenuItem::maxIconWidth

This variable 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. The default value is 0.

bool QStyleOptionMenuItem::menuHasCheckableItems

This variable holds whether the menu as a whole has checkable items or not. If this option is set to false, then the menu has no checkable items. This makes it possible for GUI styles to save some horizontal space that would normally be used for the check column. The default value is true.

QStyleOptionMenuItem::MenuItemType QStyleOptionMenuItem::menuItemType

This variable holds the type of menu item. The default value is QStyleOptionMenuItem::Normal.

See also
MenuItemType
QRect QStyleOptionMenuItem::menuRect

This variable holds the rectangle for the entire menu. The default value is a null rectangle, i.e. a rectangle with both the width and the height set to 0.

QString QStyleOptionMenuItem::text

This variable holds the text for the menu item. The text format will be something like this "Menu text\tShortcut". If the menu item does not have a shortcut it will just contain the text for menu item. The default value is an empty string.