Qt Reference Documentation

QML ContextMenu Element

Provides a component with list of options that the user can choose from. More...

Inherits Item

  • List of all members, including inherited members
  • Properties

    Methods

    Detailed Description

    There are two typical use cases for the ContextMenu component. You can use it as a context sensitive menu that opens, for example, on an object's long press signal, or you can use it to show a submenu.

    The following code snippet shows how to create a ContextMenu.

     ContextMenu {
         id: cmykMenu
         MenuLayout {
             MenuItem {
                 text: "Cyan"
                 onClicked: rect.color = "Cyan"
             }
                 ...
         }
     }

    See the Menu documentation for an example on how to use a ContextMenu as a submenu.

    Property Documentation

    read-onlydefaultcontent : list<Item>

    Provides access to the menu items in the context menu. It is recommended to use a single MenuLayout instance as the context menu content. Usage of other objects may result in unexpected behaviour.


    status : int

    Indicates the status of a context menu. The possible values are as follows:

    • DialogStatus.Opening - the menu is opening
    • DialogStatus.Open - the menu is open and visible to the user
    • DialogStatus.Closing - the menu is closing
    • DialogStatus.Closed - the menu is closed and not visible to the user

    read-onlyvisualParent : Item

    This property is not used in Symbian. The context menu always uses the predefined position and fading policy.


    Method Documentation

    ContextMenu::close ()

    Hides the context menu from the user.

    Normally a context menu is closed when the user selects an item from the menu. Context menu is also closed when the user clicks outside the menu.


    ContextMenu::open ()

    Shows the context menu to the user.