IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

MenuStyle QML Type

Provides custom styling for Menu.

This type was introduced in Qt 5.3.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

MenuStyle QML Type

  • Import Statement: import QtQuick.Controls.Styles 1.4

  • Since: Qt 5.3

  • Group: MenuStyle is part of Styling Controls

Detailed Description

 

The styleData object contains the following read-only properties:

styleData.index : int

The index of the menu item in its menu.

styleData.type : enumeration

The type of menu item. See below for possible values.

styleData.selected : bool

true if the menu item is selected.

styleData.pressed : bool

true if the menu item is pressed. Available since 5.4.

styleData.text : string

The menu item's text, or title if it's a submenu.

styleData.underlineMnemonic : bool

Whether the style should underline the menu item's label mnemonic.

styleData.shortcut : string

The text for the menu item's shortcut.

styleData.iconSource : url

The source URL to the menu item's icon. Undefined if it has no icon.

styleData.enabled : bool

true if the menu item is enabled.

styleData.checkable : bool

true if the menu item is checkable.

styleData.exclusive : bool

true if the menu item is checkable, and it's part of an ExclusiveGroup.

styleData.checked : bool

true if the menu item is checkable and currently checked.

styleData.scrollerDirection : enumeration

If 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:

  • MenuItemType.Item

  • MenuItemType.Menu

  • MenuItemType.Separator

  • MenuItemType.ScrollIndicator

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

Property Documentation

 

[since QtQuick.Controls.Styles 1.3] font : font

The font of the control.

This 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:

  • itemDelegate.background : Component

    The menu item background component.

    Its appearance generally changes with styleData.selected and styleData.enabled.

    The default implementation shows only when the item is enabled and selected. It remains invisible otherwise.

  • itemDelegate.label : Component

    Component for the actual text label.

    The text itself is fetched from styleData.text, and its appearance should depend on styleData.enabled and styleData.selected.

    If styleData.underlineMnemonic is true, the label should underline its mnemonic character. formatMnemonic provides the default formatting.

  • itemDelegate.submenuIndicator : Component

    It indicates that the current menu item is a submenu.

    Only used when styleData.type equals MenuItemType.Menu.

  • itemDelegate.shortcut : Component

    Displays the shortcut attached to the menu item.

    Only used when styleData.shortcut is not empty.

  • itemDelegate.checkmarkIndicator : Component

    Will be used when styleData.checkable is true and its appearance may depend on styleData.exclusive, i.e., whether it will behave like a checkbox or a radio button. Use styleData.checked for the checked state.

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

padding group

padding.bottom : int

padding.left : int

padding.right : int

padding.top : int

This grouped property holds the top, left, right and bottom padding.

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.

submenuOverlap : int

submenuPopupDelay : int

Method Documentation

 

string formatMnemonic(string text, bool underline = false)

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

See also Label

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+