Menu QML Type

A menu control. More...

Import Statement: import Qt.labs.controls 1.0




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"

    Menu {
        id: menu
        y: fileButton.height

        MenuItem {
            text: "New..."
        MenuItem {
            text: "Open..."
        MenuItem {
            text: "Save"

Note: Types in the Qt.labs module are not guaranteed to remain compatible in future versions.

See also Customizing Menu and Menu Controls.

Property Documentation

[default] contentData : list<Object>

This property holds the list of content data.

See also Item::data.

[read-only] contentModel : model

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 : string

Title for the menu as a submenu or in a menubar.

Its value defaults to an empty string.

Method Documentation

void addItem(Item item)

Adds item to the end of the list of items.

void insertItem(int index, Item item)

Inserts item at index.

Item itemAt(int index)

Returns the item at index, or null if it does not exist.

void moveItem(int from, int to)

Moves an item from one index to another.

void removeItem(int index)

Removes an item at index.

Note: The ownership of the item is transferred to the caller.

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.