Menu QML Type
A menu control that can be used as a context menu or popup menu. More...
Import Statement: | import QtQuick.Controls 2.0 |
Since: | Qt 5.7 |
Inherits: |
Properties
- contentData : list<Object>
- contentModel : model
- title : string
Methods
- void addItem(Item item)
- void insertItem(int index, Item item)
- Item itemAt(int index)
- void moveItem(int from, int to)
- void removeItem(int index)
Detailed Description
Menu has two main use cases:
- Context menus; for example, a menu that is shown after right clicking
- Popup menus; for example, a menu that is shown after clicking a button
Button { id: fileButton text: "File" onClicked: menu.open() Menu { id: menu y: fileButton.height MenuItem { text: "New..." } MenuItem { text: "Open..." } MenuItem { text: "Save" } } }
See also Customizing Menu, Menu Controls, and Popup Controls.
Property Documentation
This property holds the list of content data.
See also Item::data.
This property holds the model used to display menu items.
By default, the model is an ObjectModel, in order to allow declaring menu items as children of the menu.
Title for the menu as a submenu or in a menubar.
Its value defaults to an empty string.
Method Documentation
Removes an item at index.
Note: The ownership of the item is transferred to the caller.