MenuBar QML Type
ウィンドウ・メニュー・バーを提供します。詳細...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
プロパティ
方法
- void addMenu(Menu menu)
- void insertMenu(int index, Menu menu)
- Menu menuAt(int index)
- void removeMenu(Menu menu)
- Menu takeMenu(int index)
詳細説明

MenuBarはドロップダウンメニューで構成され、通常はウィンドウの上端に配置される。
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") } } } }
通常、メニューはメニュー・バーの子として静的に宣言されるが、MenuBarはadd 、insert 、remove 、take メニューへのAPIも動的に提供する。メニュー・バーのメニューにはmenuAt() を使ってアクセスできる。
ネイティブメニューバー
Qt 6.8以降、MenuBarはmacOSのネイティブメニューバーとして実装されています。その結果、MenuBar 内のすべての Menu、MenuItems、MenuBarItems もネイティブになります。これには、すべてがネイティブに見えるという利点がありますが、前述のコントロールに設定されたデリゲートがレンダリングに使用されないという欠点もあります。ネイティブのMenuBarが不要な場合は、QGuiApplication::setAttribute(Qt::AA_DontUseNativeMenuBar) 。
Menu のMenuBar のカスタマイズ、MenuBarItem のメニューコントロール、 Qt Quick Controls のフォーカス管理も参照してください 。
プロパティ・ドキュメント
delegate : Component
このプロパティは、メニューバーにメニューを表示するためのメニューバーアイテムを作成するために使用されるコンポーネントを保持します。
MenuBar はデリゲートの所有権を持ちません。
MenuBarItemも参照してください 。
menus : list<Menu>
このプロパティはメニューのリストを保持する。
このリストには、メニューバーの子メニューとして QML で宣言されたすべてのメニューと、addMenu() メソッドおよびinsertMenu() メソッドを用いて動的に追加または挿入されたメニューが含まれます。
メソッドのドキュメント
void addMenu(Menu menu)
menu をメニューリストの最後に追加する。
void insertMenu(int index, Menu menu)
index にmenu を挿入する。
Menu menuAt(int index)
index にあるメニューを返し、存在しない場合はnull を返す。
void removeMenu(Menu menu)
指定されたmenu を削除する。メニューがopen の場合、まずdismissed が削除されます。menu は最終的にガベージコレクタによって削除されます。
Menu takeMenu(int index)
index のメニューを削除して返す。メニューがopen の場合、まずdismissed になります。メニューは最終的にガベージコレクタによって削除されます。
© 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.