In questa pagina

MenuBar QML Type

Una barra dei menu nativa. Altro...

Import Statement: import Qt.labs.platform
Inherits:

QtObject

Proprietà

Metodi

Descrizione dettagliata

Il tipo MenuBar fornisce un'API QML per le barre dei menu native della piattaforma.

Una barra dei menu nativa

Una barra dei menu è costituita da un elenco di menu a tendina.

MenuBar {
    id: menuBar

    Menu {
        id: fileMenu
        title: qsTr("File")
        // ...
    }

    Menu {
        id: editMenu
        title: qsTr("&Edit")
        // ...
    }

    Menu {
        id: viewMenu
        title: qsTr("&View")
        // ...
    }

    Menu {
        id: helpMenu
        title: qsTr("&Help")
        // ...
    }
}

MenuBar è attualmente disponibile sulle seguenti piattaforme:

  • macOS
  • Android
  • Linux (disponibile solo su ambienti desktop che forniscono una barra dei menu D-Bus globale)
  • Windows

Nota: non è garantita la compatibilità dei tipi nei moduli Qt.labs nelle versioni future.

Vedi anche Menu.

Documentazione sulle proprietà

data : list<QtObject> [default]

Questa proprietà predefinita contiene l'elenco di tutti gli oggetti dichiarati come figli della barra dei menu. La proprietà “data” include oggetti che non sono istanze di ` Menu `, come ` Timer ` e ` QtObject`.

Vedi anche menus.

Questa proprietà contiene l'elenco dei menu presenti nella barra dei menu.

window : Window

Questa proprietà contiene la finestra della barra dei menu.

Se non viene impostata esplicitamente, la finestra viene individuata automaticamente iterando gli oggetti padre QML fino a quando non viene trovato un oggetto ` Window ` o un oggetto ` Item ` che disponga di una finestra.

Documentazione dei metodi

void addMenu(Menu menu)

Aggiunge un'icona “ menu ” alla fine della barra dei menu.

void clear()

Rimuove tutti i menu dalla barra dei menu.

void insertMenu(int index, Menu menu)

Inserisce un'icona " menu " nell'index e specificata nella barra dei menu.

void removeMenu(Menu menu)

Rimuove un " menu " dalla barra dei menu.

© 2026 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.