本页内容

菜单控件

ContextMenu

“Attached”类型提供了一种以适合平台的方式打开上下文菜单的方法

Menu

可作为上下文菜单或弹出菜单使用的弹出窗口

MenuBar

提供窗口菜单栏

MenuBarItem

在 MenuBar 中显示下拉菜单

MenuItem

在菜单中显示一个项目

每种菜单控件都有其特定的适用场景。以下各节提供了根据具体场景选择合适菜单控件类型的指南。

显示带快捷键选项的菜单

Menu 控件可用于上下文菜单;例如,右键单击后显示的菜单。它也可用于弹出菜单;例如,单击按钮后显示的菜单。

MenuItem 是“菜单”控件中的一个项目。菜单中的每个项目:

  • 向用户显示文本
  • 支持选中/取消选中
  • 被高亮显示(例如,在键盘导航时)
  • 在激活时执行某些操作

包含“文件”、“编辑”和“视图”菜单的菜单栏

MenuBar 该控件可用于窗口菜单栏。

MenuBarItem 是MenuBar 控件中的一个项目。菜单栏中的每个项目:

  • 向用户显示文本
  • 被高亮显示(例如,在键盘导航时)
  • 在激活时弹出相应的菜单

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