MenuStyle QML Type

Provides custom styling for Menu More...

Import Statement: import QtQuick.Controls.Styles .
Since: Qt 5.3

Properties

Methods

Detailed Description

The styleData object contains the following read-only properties:

styleData.index : intThe index of the menu item in its menu.
styleData.type : enumerationThe type of menu item. See below for possible values.
styleData.selected : booltrue if the menu item is selected.
styleData.pressed : booltrue if the menu item is pressed. Available since 5.4.
styleData.text : stringThe menu item's text, or title if it's a submenu.
styleData.underlineMnemonic : boolWhether the style should underline the menu item's label mnemonic.
styleData.shortcut : stringThe text for the menu item's shortcut.
styleData.iconSource : urlThe source URL to the menu item's icon. Undefined if it has no icon.
styleData.enabled : booltrue if the menu item is enabled.
styleData.checkable : booltrue if the menu item is checkable.
styleData.exclusive : booltrue if the menu item is checkable, and it's part of an ExclusiveGroup.
styleData.checked : booltrue if the menu item is checkable and currently checked.
styleData.scrollerDirection : enumerationIf the menu item is a scroller, its pointing direction. Valid values are Qt.UpArrow, Qt.DownArrow, and Qt.NoArrow.

The valid values for styleData.type are:

Note: Styling menus may not be supported on platforms using native menus through their QPA plugin.

Property Documentation

font : font

The font of the control.

This QML property was introduced in QtQuick.Controls.Styles 1.3.


frame : Component

The background frame for the menu popup.

The Menu will resize the frame to its contents plus the padding.


itemDelegate : Object

The object containing the menu item subcontrol components. These subcontrols are used for normal menu items only, i.e. not for separators or scroll indicators.

The subcontrols are:

Note: This property cannot be overwritten although all of the subcontrol properties can.


scrollIndicator : Component

Component for the scroll indicator menu item.

Will be used when styleData.type equals MenuItemType.ScrollIndicator. Its appearance should follow styleData.scrollerDirection.

This is the item added at the top and bottom of the menu popup when its contents won't fit the screen to indicate more content is available in the direction of the arrow.


separator : Component

Component for the separator menu item.

Will be used when styleData.type equals MenuItemType.Separator.


The amount of pixels by which a submenu popup overlaps horizontally its parent menu.


The number of milliseconds to wait before opening a submenu.


Method Documentation

formatMnemonic( text, underline)

Returns a rich-text string to render mnemonics for a given menu item.

The mnemonic character is prefixed by an ampersand in the original string.

Passing true for underline will underline the mnemonic character (e.g., formatMnemonic("&Open...", true) will return "<u>O</u>pen..."). Passing false for underline will return the plain text form (e.g., formatMnemonic("&Open...", false) will return "Open...").

See also Label.