<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QStyleOptionMenuItem Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QStyleOptionMenuItem Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item. <a href="#details">More...</a></p> <p>Inherits <a href="qstyleoption.html">QStyleOption</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qstyleoptionmenuitem.html#CheckType-enum">CheckType</a></b> { NotCheckable, Exclusive, NonExclusive }</li><li><div class="fn" />enum <b><a href="qstyleoptionmenuitem.html#MenuItemType-enum">MenuItemType</a></b> { Normal, DefaultItem, Separator, SubMenu, ..., EmptyArea }</li><li><div class="fn" />enum <b><a href="qstyleoptionmenuitem.html#StyleOptionType-enum">StyleOptionType</a></b> { Type }</li><li><div class="fn" />enum <b><a href="qstyleoptionmenuitem.html#StyleOptionVersion-enum">StyleOptionVersion</a></b> { Version }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstyleoptionmenuitem.html#QStyleOptionMenuItem">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstyleoptionmenuitem.html#QStyleOptionMenuItem-2">__init__</a></b> (<i>self</i>, QStyleOptionMenuItem <i>other</i>)</li></ul><h3>Members</h3><ul><li><div class="fn" />bool <b><a href="qstyleoptionmenuitem.html#checked-var">checked</a></b></li><li><div class="fn" />CheckType <b><a href="qstyleoptionmenuitem.html#checkType-var">checkType</a></b></li><li><div class="fn" />QFont <b><a href="qstyleoptionmenuitem.html#font-var">font</a></b></li><li><div class="fn" />QIcon <b><a href="qstyleoptionmenuitem.html#icon-var">icon</a></b></li><li><div class="fn" />int <b><a href="qstyleoptionmenuitem.html#maxIconWidth-var">maxIconWidth</a></b></li><li><div class="fn" />bool <b><a href="qstyleoptionmenuitem.html#menuHasCheckableItems-var">menuHasCheckableItems</a></b></li><li><div class="fn" />MenuItemType <b><a href="qstyleoptionmenuitem.html#menuItemType-var">menuItemType</a></b></li><li><div class="fn" />QRect <b><a href="qstyleoptionmenuitem.html#menuRect-var">menuRect</a></b></li><li><div class="fn" />int <b><a href="qstyleoptionmenuitem.html#tabWidth-var">tabWidth</a></b></li><li><div class="fn" />QString <b><a href="qstyleoptionmenuitem.html#text-var">text</a></b></li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item.</p> <p>QStyleOptionMenuItem contains all the information that <a href="qstyle.html">QStyle</a> functions need to draw the menu items from <a href="qmenu.html">QMenu</a>. It is also used for drawing other menu-related widgets.</p> <p>For performance reasons, the access to the member variables is direct (i.e., using the <tt>.</tt> or <tt>-></tt> operator). This low-level feel makes the structures straightforward to use and emphasizes that these are simply parameters used by the style functions.</p> <p>For an example demonstrating how style options can be used, see the <a href="widgets-styles.html">Styles</a> example.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="CheckType-enum" />QStyleOptionMenuItem.CheckType</h3><p>This enum is used to indicate whether or not a check mark should be drawn for the item, or even if it should be drawn at all.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"> <tt>QStyleOptionMenuItem.NotCheckable</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">The item is not checkable.</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Exclusive</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">The item is an exclusive check item (like a radio button).</td> </tr> <tr> <td class="topAlign"> <tt>QStyleOptionMenuItem.NonExclusive</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">The item is a non-exclusive check item (like a check box).</td> </tr> </table> <p><b>See also</b> <a href="qstyleoptionmenuitem.html#checkType-var">checkType</a>, <a href="qaction.html#checkable-prop">QAction.checkable</a>, <a href="qaction.html#checked-prop">QAction.checked</a>, and <a href="qactiongroup.html#exclusive-prop">QActionGroup.exclusive</a>.</p> <h3 class="fn"><a name="MenuItemType-enum" />QStyleOptionMenuItem.MenuItemType</h3><p>This enum indicates the type of menu item that the structure describes.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Normal</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">A normal menu item.</td> </tr> <tr> <td class="topAlign"> <tt>QStyleOptionMenuItem.DefaultItem</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">A menu item that is the default action as specified with <a href="qmenu.html#defaultAction">QMenu.defaultAction</a>().</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Separator</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">A menu separator.</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.SubMenu</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">Indicates the menu item points to a sub-menu.</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Scroller</tt></td> <td class="topAlign"><tt>4</tt></td> <td class="topAlign">A popup menu scroller (currently only used on Mac OS X).</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.TearOff</tt></td> <td class="topAlign"><tt>5</tt></td> <td class="topAlign">A tear-off handle for the menu.</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Margin</tt></td> <td class="topAlign"><tt>6</tt></td> <td class="topAlign">The margin of the menu.</td> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.EmptyArea</tt></td> <td class="topAlign"><tt>7</tt></td> <td class="topAlign">The empty area of the menu.</td> </tr> </table> <p><b>See also</b> <a href="qstyleoptionmenuitem.html#menuItemType-var">menuItemType</a>.</p> <h3 class="fn"><a name="StyleOptionType-enum" />QStyleOptionMenuItem.StyleOptionType</h3><p>This enum is used to hold information about the type of the style option, and is defined for each <a href="qstyleoption.html">QStyleOption</a> subclass.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Type</tt></td> <td class="topAlign"><tt>SO_MenuItem</tt></td> <td class="topAlign">The type of style option provided (<a href="qstyleoption.html#OptionType-enum">SO_MenuItem</a> for this class).</td> </tr> </table> <p>The type is used internally by <a href="qstyleoption.html">QStyleOption</a>, its subclasses, and <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>() to determine the type of style option. In general you do not need to worry about this unless you want to create your own <a href="qstyleoption.html">QStyleOption</a> subclass and your own styles.</p> <p><b>See also</b> <a href="qstyleoptionmenuitem.html#StyleOptionVersion-enum">StyleOptionVersion</a>.</p> <h3 class="fn"><a name="StyleOptionVersion-enum" />QStyleOptionMenuItem.StyleOptionVersion</h3><p>This enum is used to hold information about the version of the style option, and is defined for each <a href="qstyleoption.html">QStyleOption</a> subclass.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QStyleOptionMenuItem.Version</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">1</td> </tr> </table> <p>The version is used by <a href="qstyleoption.html">QStyleOption</a> subclasses to implement extensions without breaking compatibility. If you use <a href="qstyleoption.html#qstyleoption_cast">qstyleoption_cast</a>(), you normally do not need to check it.</p> <p><b>See also</b> <a href="qstyleoptionmenuitem.html#StyleOptionType-enum">StyleOptionType</a>.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStyleOptionMenuItem" />QStyleOptionMenuItem.__init__ (<i>self</i>)</h3><p>Constructs a <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a>, initializing the members variables to their default values.</p> <h3 class="fn"><a name="QStyleOptionMenuItem-2" />QStyleOptionMenuItem.__init__ (<i>self</i>, <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a> <i>other</i>)</h3><p>Constructs a copy of the <i>other</i> style option.</p> <hr /><h2>Member Documentation</h2><h3 class="fn"><a name="checked-var" />bool checked</h3><p>This variable holds whether the menu item is checked or not.</p> <p>The default value is false.</p> <h3 class="fn"><a name="checkType-var" /><a href="qstyleoptionmenuitem.html#CheckType-enum">CheckType</a> checkType</h3><p>This variable holds the type of checkmark of the menu item.</p> <p>The default value is <a href="qstyleoptionmenuitem.html#CheckType-enum">NotCheckable</a>.</p> <p><b>See also</b> <a href="qstyleoptionmenuitem.html#CheckType-enum">CheckType</a>.</p> <h3 class="fn"><a name="font-var" /><a href="qfont.html">QFont</a> font</h3><p>This variable holds the font used for the menu item text.</p> <p>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's default font is used.</p> <h3 class="fn"><a name="icon-var" /><a href="qicon.html">QIcon</a> icon</h3><p>This variable holds the icon for the menu item.</p> <p>The default value is an empty icon, i.e. an icon with neither a pixmap nor a filename.</p> <h3 class="fn"><a name="maxIconWidth-var" />int maxIconWidth</h3><p>This variable holds the maximum icon width for the icon in the menu item.</p> <p>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.</p> <h3 class="fn"><a name="menuHasCheckableItems-var" />bool menuHasCheckableItems</h3><p>This variable holds whether the menu as a whole has checkable items or not.</p> <p>The default value is true.</p> <p>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.</p> <h3 class="fn"><a name="menuItemType-var" /><a href="qstyleoptionmenuitem.html#MenuItemType-enum">MenuItemType</a> menuItemType</h3><p>This variable holds the type of menu item.</p> <p>The default value is <a href="qstyleoptionmenuitem.html#MenuItemType-enum">Normal</a>.</p> <p><b>See also</b> <a href="qstyleoptionmenuitem.html#MenuItemType-enum">MenuItemType</a>.</p> <h3 class="fn"><a name="menuRect-var" /><a href="qrect.html">QRect</a> menuRect</h3><p>This variable holds the rectangle for the entire menu.</p> <p>The default value is a null rectangle, i.e. a rectangle with both the width and the height set to 0.</p> <h3 class="fn"><a name="tabWidth-var" />int tabWidth</h3><p>This variable holds the tab width for the menu item.</p> <p>The tab width is the distance between the text of the menu item and the shortcut. The default value is 0.</p> <h3 class="fn"><a name="text-var" />QString text</h3><p>This variable holds the text for the menu item.</p> <p>Note that the text format is something like this "Menu text<b>\t</b>Shortcut".</p> <p>If the menu item doesn't have a shortcut, it will just contain the menu item's text. The default value is an empty string.</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>