MenuItem provides an item to add in a menu or a menu bar. 更多...
import 语句: | import QtQuick.Controls 1.4 |
Menu { text: "Edit" MenuItem { text: "Cut" shortcut: "Ctrl+X" onTriggered: ... } MenuItem { text: "Copy" shortcut: "Ctrl+C" onTriggered: ... } MenuItem { text: "Paste" shortcut: "Ctrl+V" onTriggered: ... } }
另请参阅 MenuBar , Menu , MenuSeparator ,和 动作 .
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
,和
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.
默认为
null
, meaning no action is bound to the menu item.
checkable : bool |
Whether the menu item can be checked, or toggled. Defaults to
false
.
另请参阅 checked .
checked : bool |
If the menu item is checkable, this property reflects its checked state. Defaults to
false
.
另请参阅 checkable and 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 动作 sharing it, become mutually exclusive selectable, meaning that only the last checked menu item will actually be checked.
默认为
null
, meaning no exclusive behavior is to be expected.
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 .
另请参阅 iconSource and 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.
另请参阅 iconName and Action::iconSource .
Shortcut bound to the menu item. The keysequence can be a string or a 标准键 .
Defaults to an empty string.
MenuItem { id: copyItem text: qsTr("&Copy") shortcut: StandardKey.Copy }
另请参阅 Action::shortcut .
text : string |
Text for the menu item. Overrides the item's bound action
text
特性。
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.
另请参阅 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
.
Emitted whenever a menu item's checked property changes. This usually happens at the same time as triggered .
相应处理程序是
onToggled
.
注意:
相应处理程序是
onToggled
.
另请参阅 checked , triggered , Action::triggered , Action::toggled ,和 checked .
Emitted when either the menu item or its bound action have been activated.
相应处理程序是
onTriggered
.
注意:
相应处理程序是
onTriggered
.
另请参阅 trigger() , Action::triggered ,和 Action::toggled .
Manually trigger a menu item. Will also trigger the item's bound action.
另请参阅 triggered and Action::trigger() .