IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

MenuBar QML Type

Provides a window menu bar.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

MenuBar QML Type

  • Import Statement: import QtQuick.Controls

  • Inherits: Container

  • Group: MenuBar is part of qtquickcontrols-menus, qtquickcontrols-focusscopes

Detailed Description

Image non disponible

MenuBar consists of drop-down menus, and is normally located at the top edge of the window.

 
Sélectionnez
ApplicationWindow {
    id: window
    width: 320
    height: 260
    visible: true

    menuBar: MenuBar {
        Menu {
            title: qsTr("&File")
            Action { text: qsTr("&New...") }
            Action { text: qsTr("&Open...") }
            Action { text: qsTr("&Save") }
            Action { text: qsTr("Save &As...") }
            MenuSeparator { }
            Action { text: qsTr("&Quit") }
        }
        Menu {
            title: qsTr("&Edit")
            Action { text: qsTr("Cu&t") }
            Action { text: qsTr("&Copy") }
            Action { text: qsTr("&Paste") }
        }
        Menu {
            title: qsTr("&Help")
            Action { text: qsTr("&About") }
        }
    }
}

Typically, menus are statically declared as children of the menu bar, but MenuBar also provides API to add, insert, remove, and take menus dynamically. The menus in a menu bar can be accessed using menuAt().

See Also

Property Documentation

 

[since QtQuick.Controls 2.3 (Qt 5.10)] contentHeight : real

This property holds the content height. It is used for calculating the total implicit height of the menu bar.

This property is available in MenuBar since QtQuick.Controls 2.3 (Qt 5.10), but it was promoted to the Container base type in QtQuick.Controls 2.5 (Qt 5.12).

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See Also

[since QtQuick.Controls 2.3 (Qt 5.10)] contentWidth : real

This property holds the content width. It is used for calculating the total implicit width of the menu bar.

This property is available in MenuBar since QtQuick.Controls 2.3 (Qt 5.10), but it was promoted to the Container base type in QtQuick.Controls 2.5 (Qt 5.12).

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See Also

delegate : Component

This property holds the component that is used to create menu bar items to present menus in the menu bar.

See Also

See also MenuBarItem

menus : list<Menu>

The list contains all menus that have been declared in QML as children of the menu bar, and also menus that have been dynamically added or inserted using the addMenu() and insertMenu() methods, respectively.

Method Documentation

 

void addMenu(Menu menu)

Adds menu to the end of the list of menus.

void insertMenu(int index, Menu menu)

Inserts menu at index.

Menu menuAt(int index)

void removeMenu(Menu menu)

Removes and destroys the specified menu.

Menu takeMenu(int index)

Removes and returns the menu at index.

The ownership of the item is transferred to the caller.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+