MenuItem QML Type

  • Import Statement: import Qt.labs.platform 1.1

  • Since: Qt 5.8

  • Inherited By:: MenuSeparator

  • Inherits: QtObject

Detailed Description

The MenuItem type provides a QML API for native platform menu items.

Image non disponible

A menu item consists of an icon, text, and shortcut.

 
Sélectionnez
Menu {
    id: zoomMenu

    MenuItem {
        text: qsTr("Zoom In")
        shortcut: StandardKey.ZoomIn
        onTriggered: zoomIn()
    }

    MenuItem {
        text: qsTr("Zoom Out")
        shortcut: StandardKey.ZoomOut
        onTriggered: zoomOut()
    }
}

Types in Qt.labs modules are not guaranteed to remain compatible in future versions.

See Also

See also Menu, MenuItemGroup

Property Documentation

 

checkable : bool

This property holds whether the item is checkable.

A checkable menu item has an on/off state. For example, in a word processor, a "Bold" menu item may be either on or off. A menu item that is not checkable is a command item that is simply executed, e.g. file save.

The default value is false.

See Also

checked : bool

This property holds whether the item is checked (on) or unchecked (off). The default value is false.

See Also

enabled : bool

This property holds whether the item is enabled. The default value is true.

Disabled items cannot be triggered by the user. They do not disappear from menus, but they are displayed in a way which indicates that they are unavailable. For example, they might be displayed using only shades of gray.

When an item is disabled, it is not possible to trigger it through its shortcut.

font : font

This property holds the menu item's font.

See Also

See also text

group : MenuItemGroup

This property holds the group that the item belongs to, or null if the item is not in a group.

icon group

[since Qt.labs.platform 1.1 (Qt 5.12)] icon.mask : bool

[since Qt.labs.platform 1.1 (Qt 5.12)] icon.name : string

[since Qt.labs.platform 1.1 (Qt 5.12)] icon.source : url

This property holds the menu item's icon.