Provides of a list of options that the user can choose from. More...
This element was introduced in Qt Quick Components 1.0.
A Menu is hidden by default and opens in response to a user action. When the user selects an option in the menu, it triggers a command.
The code snippet below shows how to create a Menu.
// define the menu Menu { id: mainMenu // define the items in the menu and corresponding actions content: MenuLayout { MenuItem { text: "Red" onClicked: rect.color = "Red" } ... } }
The code snippet below shows how the user can launch the menu by pressing the ToolBar's menu button.
ToolBar { id: toolbar anchors.bottom: parent.bottom tools: ToolBarLayout { ToolButton { iconSource: "toolbar-back" } // add the standard menu button to the toolbar ToolButton { iconSource: "toolbar-menu" onClicked: mainMenu.open() } } }
A menu opened from a tool bar
A Menu can contain submenus that are normally implemented with ContextMenu objects. The code snippet below shows how to define a ContextMenu.
ContextMenu { id: cmykMenu MenuLayout { MenuItem { text: "Cyan" onClicked: rect.color = "Cyan" } ... } }
You can integrate a submenu to a menu by setting its MenuItem.platformSubItemIndicator property to true. The following code snippet shows how a submenu is integrated to the menu item.
MenuItem { text: "CMYK menu" platformSubItemIndicator: true onClicked: cmykMenu.open() }
Provides access to the menu items in the menu. It is recommended to use a single MenuLayout object as the menu content. Usage of other objects may result in unexpected behaviour.
Symbian:
If platformInverted is true, the component is visualized with the inverted style. For more information, see Using Inverted Style with Symbian Components. By default platformInverted is false.
This property group was introduced in Qt Quick Components 1.1.
Indicates the status of a menu. The possible values are as follows:
This property is not used in Symbian. The menu always uses predefined position and fading policy.
Hides the menu from the user.
Normally a menu is closed when the user selects an item from the menu. Menu is also closed when the user clicks outside the menu.
Shows the menu to the user. See the code snippet above for an example how to bind a signal to this method.