Presents an item within a Menu. 更多...
import 语句: | import QtQuick.Controls 2.2 |
Since: | Qt 5.7 |
继承: | AbstractButton |
MenuItem is a convenience type that implements the AbstractButton API, providing a familiar way to respond to menu items being triggered ,例如。
MenuItem inherits its API from AbstractButton . For instance, you can set text and icon 使用 AbstractButton API.
Button { id: fileButton text: "File" onClicked: menu.open() Menu { id: menu MenuItem { text: "New..." onTriggered: document.reset() } MenuItem { text: "Open..." onTriggered: openDialog.open() } MenuItem { text: "Save" onTriggered: saveDialog.open() } } }
另请参阅 Customizing Menu , Menu ,和 菜单控件 .
[since QtQuick.Controls 2.3 (Qt 5.10)] arrow : Item |
This property holds the sub-menu arrow item.
该特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。
另请参阅 Customizing Menu .
highlighted : bool |
This property holds whether the menu item is highlighted by the user.
A menu item can be highlighted by mouse hover or keyboard navigation.
默认值为
false
.
另请参阅 Menu::currentIndex .
[read-only, since QtQuick.Controls 2.3 (Qt 5.10)] menu : Menu |
This property holds the menu that contains this menu item, or
null
if the item is not in a menu.
该特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。
[read-only, since QtQuick.Controls 2.3 (Qt 5.10)] subMenu : Menu |
This property holds the sub-menu that this item presents in the parent menu, or
null
if this item is not a sub-menu item.
该特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。
void triggered () |
This signal is emitted when the menu item is triggered by the user.
注意:
相应处理程序是
onTriggered
.