MenuItem QML Type▲
-
Import Statement: import QtQuick.Controls 1.4
-
Group: MenuItem is part of Menus, Buttons and Controls
Detailed Description▲
Menu {
text
:
"Edit"
MenuItem {
text
:
"Cut"
shortcut
:
"Ctrl+X"
onTriggered
:
...
}
MenuItem {
text
:
"Copy"
shortcut
:
"Ctrl+C"
onTriggered
:
...
}
MenuItem {
text
:
"Paste"
shortcut
:
"Ctrl+V"
onTriggered
:
...
}
}
See Also▲
See also MenuBar, Menu, MenuSeparator, Action
Property Documentation▲
action : Action▲
The action bound to this menu item. It will provide values for all the properties of the menu item. However, it is possible to override the action's text, iconSource, and iconName properties by just assigning these properties, allowing some customization.
In addition, the menu item triggered() and toggled() signals will not be emitted. Instead, the action triggered() and toggled() signals will be.
Defaults to null, meaning no action is bound to the menu item.
checkable : bool▲
checked : bool▲
If the menu item is checkable, this property reflects its checked state. Defaults to false.
See Also▲
See also checkable, Action::toggled
enabled : bool▲
Whether the menu item is enabled, and responsive to user interaction. Defaults to true.
exclusiveGroup : ExclusiveGroup▲
If a menu item is checkable, an ExclusiveGroup can be attached to it. All the menu items sharing the same exclusive group, and by extension, any Action sharing it, become mutually exclusive selectable, meaning that only the last checked menu item will actually be checked.
Defaults to null, meaning no exclusive behavior is to be expected.
See Also▲
iconName : string▲
Sets the icon name for the MenuItem icon. This will pick the icon with the given name from the current theme. Overrides the item's bound action iconName property. Defaults to an empty string.
This property requires QApplication.
See Also▲
See also iconSource, Action::iconName
iconSource : url▲
Sets the icon file or resource url for the MenuItem icon. Overrides the item's bound action iconSource property. Defaults to an empty URL.
See Also▲
See also iconName, Action::iconSource
shortcut : keysequence▲
Shortcut bound to the menu item. The keysequence can be a string or a standard key.
Defaults to an empty string.
MenuItem
{
id
:
copyItem
text
:
qsTr("&Copy"
)
shortcut
:
StandardKey.Copy
}
See Also▲
See also Action::shortcut
text : string▲
Text for the menu item. Overrides the item's bound action text property.
Mnemonics are supported by prefixing the shortcut letter with &. For instance, "\&Open" will bind the Alt-O shortcut to the "Open" menu item. Note that not all platforms support mnemonics.
Defaults to an empty string.
See Also▲
See also Action::text
[read-only] type : enumeration▲
This property is read-only and constant, and its value is MenuItemType.Item.
visible : bool▲
Whether the menu item should be visible. Defaults to true.
Signal Documentation▲
toggled(checked)▲
Emitted whenever a menu item's checked property changes. This usually happens at the same time as triggered.
The corresponding handler is onToggled.
The corresponding handler is onToggled.
See Also▲
See also checked, triggered, Action::triggered, Action::toggled
triggered()▲
Emitted when either the menu item or its bound action have been activated.
The corresponding handler is onTriggered.
The corresponding handler is onTriggered.
See Also▲
See also trigger(), Action::triggered, Action::toggled
Method Documentation▲
void trigger()▲
Manually trigger a menu item. Will also trigger the item's bound action.
See Also▲
See also triggered, Action::trigger()