def
actionAt
(arg__1)
def
actionGeometry
(arg__1)
def
activeAction
()
def
addAction
(arg__1, arg__2)
def
addAction
(text)
def
addAction
(text, receiver, member)
def
addMenu
(icon, title)
def
addMenu
(menu)
def
addMenu
(title)
def
addSeparator
()
def
clear
()
def
cornerWidget
([corner=Qt.TopRightCorner])
def
initStyleOption
(option, action)
def
insertMenu
(before, menu)
def
insertSeparator
(before)
def
isDefaultUp
()
def
isNativeMenuBar
()
def
setActiveAction
(action)
def
setCornerWidget
(w[, corner=Qt.TopRightCorner])
def
setDefaultUp
(arg__1)
def
setNativeMenuBar
(nativeMenuBar)
菜单栏由下拉菜单项列表组成。添加菜单项采用
addMenu(). For example, asuming thatmenubar是指针指向QMenuBarandfileMenu是指针指向QMenu,以下语句将菜单插入菜单栏:menubar.addMenu(fileMenu)The ampersand in the menu item’s text sets Alt+F as a shortcut for this menu. (You can use “&&” to get a real ampersand in the menu bar.)
There is no need to lay out a menu bar. It automatically sets its own geometry to the top of the parent widget and changes it appropriately whenever the parent is resized.
In most main window style applications you would use the
menuBar()function provided inQMainWindow, addingQMenus to the menu bar and addingQActions to the pop-up menus.范例 (来自 菜单 范例):
fileMenu = menuBar().addMenu(tr("&File")) fileMenu.addAction(Act)菜单项可以被移除采用
removeAction().Widgets can be added to menus by using instances of the
QWidgetActionclass to hold them. These actions can then be inserted into menus in the usual way; see theQMenu文档编制了解更多细节。
Different platforms have different requirements for the appearance of menu bars and their behavior when the user interacts with them. For example, Windows systems are often configured so that the underlined character mnemonics that indicate keyboard shortcuts for items in the menu bar are only shown when the Alt key is pressed.
PySide2.QtWidgets.QMenuBar.
actionAt
(
arg__1
)
¶
arg__1
–
QPoint
返回
QAction
at
pt
。返回
None
若没有动作在
pt
或者若位置拥有分隔符。
PySide2.QtWidgets.QMenuBar.
actionGeometry
(
arg__1
)
¶
arg__1
–
QAction
QRect
返回几何体对于动作
act
作为
QRect
.
另请参阅
PySide2.QtWidgets.QMenuBar.
addAction
(
arg__1
,
arg__2
)
¶
arg__1 – unicode
arg__2
–
PyObject
PySide2.QtWidgets.QMenuBar.
addAction
(
text
)
¶
text – unicode
此方便函数创建新动作,采用
text
. The function adds the newly created action to the menu’s list of actions, and returns it.
另请参阅
PySide2.QtWidgets.QMenuBar.
addAction
(
text
,
receiver
,
member
)
¶
text – unicode
receiver
–
QObject
member – str
PySide2.QtWidgets.QMenuBar.
addMenu
(
icon
,
title
)
¶
icon
–
QIcon
title – unicode
追加新
QMenu
with
icon
and
title
to the menu bar. The menu bar takes ownership of the menu. Returns the new menu.
另请参阅
PySide2.QtWidgets.QMenuBar.
addMenu
(
menu
)
¶
追加
menu
to the menu bar. Returns the menu’s menuAction(). The menu bar does not take ownership of the menu.
注意
返回的
QAction
对象可以用于隐藏相应菜单。
另请参阅
PySide2.QtWidgets.QMenuBar.
clear
(
)
¶
从菜单栏移除所有动作。
注意
On macOS, menu items that have been merged to the system menu bar are not removed by this function. One way to handle this would be to remove the extra actions yourself. You can set the
menu
role
on the different menus, so that you know ahead of time which menu items get merged and which do not. Then decide what to recreate or remove yourself.
另请参阅
PySide2.QtWidgets.QMenuBar.
cornerWidget
(
[
corner=Qt.TopRightCorner
]
)
¶
corner
–
Corner
返回第一菜单项左侧或最后菜单项右侧 Widget,从属
corner
.
注意
使用角落除了
TopRightCorner
or
TopLeftCorner
将导致警告。
另请参阅
PySide2.QtWidgets.QMenuBar.
initStyleOption
(
option
,
action
)
¶
option
–
QStyleOptionMenuItem
action
–
QAction
初始化
option
采用的值来自菜单栏和信息来自
action
。此方法对子类是有用的,当需要
QStyleOptionMenuItem
, but don’t want to fill in all the information themselves.
PySide2.QtWidgets.QMenuBar.
insertMenu
(
before
,
menu
)
¶
此方便函数插入
menu
前于动作
before
并返回菜单 menuAction()。
另请参阅
PySide2.QtWidgets.QMenuBar.
insertSeparator
(
before
)
¶
此方便函数创建新分隔符动作,即:动作采用
isSeparator()
returning true. The function inserts the newly created action into this menu bar’s list of actions before action
before
and returns it.
PySide2.QtWidgets.QMenuBar.
isDefaultUp
(
)
¶
bool
PySide2.QtWidgets.QMenuBar.
isNativeMenuBar
(
)
¶
bool
PySide2.QtWidgets.QMenuBar.
setCornerWidget
(
w
[
,
corner=Qt.TopRightCorner
]
)
¶
w
–
QWidget
corner
–
Corner
This sets the given
widget
to be shown directly on the left of the first menu item, or on the right of the last menu item, depending on
corner
.
The menu bar takes ownership of
widget
, reparenting it into the menu bar. However, if the
corner
already contains a widget, this previous widget will no longer be managed and will still be a visible child of the menu bar.
注意
使用角落除了
TopRightCorner
or
TopLeftCorner
将导致警告。
另请参阅
PySide2.QtWidgets.QMenuBar.
setDefaultUp
(
arg__1
)
¶
arg__1
–
bool
另请参阅
PySide2.QtWidgets.QMenuBar.
setNativeMenuBar
(
nativeMenuBar
)
¶
nativeMenuBar
–
bool
另请参阅