A Context Menu component for selecting a menu item from a list of menu items. More...
Inherits Popup
This element was introduced in qt-components 4.7.
A Context Menu componentis for selecting a menu item from a list of menu items. Each menu item displays some text and can be associated with a custom action that is performed on the clicked signal.
The menu items are arranged in a layout via the MenuLayout element. Note that this layout and its implementation can vary depending on the UI guidelines of the platform.
PageStackWindow { id: rootWindow initialPage: Page { // long press rectangle to open the ContextMenu Rectangle { id: contextColorRect anchors.centerIn: parent width: 100; height: 100 color: "black" MouseArea { id: longPressArea anchors.fill: parent onPressAndHold: myContextMenu.open() } } // Create a menu with different menu items. ContextMenu { id: myContextMenu MenuLayout { MenuItem {text: "Red"; onClicked: { contextColorRect.color = "darkred" } } MenuItem {text: "Green"; onClicked: { contextColorRect.color = "darkgreen" }} MenuItem {text: "Blue"; onClicked: { contextColorRect.color = "darkblue" }} MenuItem {text: "Black is an extremely beautiful and stylish color"; onClicked: { contextColorRect.color = "black" }} } } } }
The visual parent property is used to specify which area of the screen is grayed out while the menu is opened. If no visual parent is set then it is determined automatically and falls back to the root item.
The ContextMenu shares most of its API with the ContextMenu component.
default property alias content: contentField.children // Common API inherited from Popup: function open() function close() property QDeclarativeItem* visualParent property int status property list<Item> title: titleBar.children // platformStyle API property Style platformStyle property string platformTitleText property Item platformIcon property Style style // Deprecated
See also MenuItem.
content : Item |
The content to be placed inside the menu.
status : int |
Returns the current status of the menu during its life cycle. Possible values: DialogStatus.Opening, DialogStatus.Opened, DialogStatus.Closing and DialogStatus.Closed.
visualParent : QDeclarativeItem* |
Property default is the root element.
The visual parent marks the element that occupies the area which is supposed to be grayed out while the menu is open.
Closes the menu and changes the status to DialogStatus.Closing for the animation phase. Once the menu is opened the status is changed to DialogStatus.Closed.
Opens the menu and changes the status to DialogStatus.Opening for the animation phase. Once the menu is opened the status is changed to DialogStatus.Open.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.