继承者: QWidgetAction
def
actionGroup
()
def
activate
(event)
def
associatedGraphicsWidgets
()
def
associatedWidgets
()
def
autoRepeat
()
def
data
()
def
font
()
def
icon
()
def
iconText
()
def
isCheckable
()
def
isChecked
()
def
isEnabled
()
def
isIconVisibleInMenu
()
def
isSeparator
()
def
isVisible
()
def
menu
()
def
menuRole
()
def
parentWidget
()
def
priority
()
def
setActionGroup
(group)
def
setAutoRepeat
(arg__1)
def
setCheckable
(arg__1)
def
setData
(var)
def
setFont
(font)
def
setIcon
(icon)
def
setIconText
(text)
def
setIconVisibleInMenu
(visible)
def
setMenu
(menu)
def
setMenuRole
(menuRole)
def
setPriority
(priority)
def
setSeparator
(b)
def
setShortcut
(shortcut)
def
setShortcutContext
(context)
def
setShortcutVisibleInContextMenu
(show)
def
setShortcuts
(arg__1)
def
setShortcuts
(shortcuts)
def
setStatusTip
(statusTip)
def
setText
(text)
def
setToolTip
(tip)
def
setWhatsThis
(what)
def
shortcut
()
def
shortcutContext
()
def
shortcuts
()
def
showStatusText
([widget=None])
def
statusTip
()
def
text
()
def
toolTip
()
def
whatsThis
()
def
hover
()
def
setChecked
(arg__1)
def
setDisabled
(b)
def
setEnabled
(arg__1)
def
setVisible
(arg__1)
def
toggle
()
def
trigger
()
在应用程序中,许多常见命令可以凭借菜单、工具栏按钮及键盘快捷键援引。由于用户期望每个命令以相同方式履行,不管所用用户界面,它是有用的将每个命令表示成 action .
动作可以被添加到菜单和工具栏,并自动保持同步。例如,在单词处理程序中,若用户按下加粗工具栏按钮,加粗菜单项将被自动选中。
可以将动作创建成独立对象,但也可以在构造菜单期间创建;
QMenu类包含用于创建适合用作菜单项的动作的方便函数。A
QActionmay contain an icon, menu text, a shortcut, status text, “What’s This?” text, and a tooltip. Most of these can be set in the constructor. They can also be set independently withsetIcon(),setText(),setIconText(),setShortcut(),setStatusTip(),setWhatsThis(),和setToolTip(). For menu items, it is possible to set an individual font withsetFont().动作被添加到 Widget 使用
addAction()oraddAction(). Note that an action must be added to a widget before it can be used; this is also true when the shortcut should be global (i.e.,ApplicationShortcutasShortcutContext).一旦
QActionhas been created it should be added to the relevant menu and toolbar, then connected to the slot which will perform the action. For example:openAct = QAction(QIcon(":/images/open.png"), tr("&Open..."), self) openAct.setShortcuts(QKeySequence.Open) openAct.setStatusTip(tr("Open an existing file")) openAct.triggered.connect(open)We recommend that actions are created as children of the window they are used in. In most cases actions will be children of the application’s main window.
QAction
(
[
parent=None
]
)
¶
QAction(icon, text[, parent=None])
QAction(text[, parent=None])
- param parent
QObject- param icon
QIcon- param text
unicode
构造动作采用
parent
。若
parent
是动作组,动作会被自动插入组中。
注意
parent
自变量是可选的,从 Qt 5.7 起。
构造动作采用
icon
和一些
text
and
parent
。若
parent
是动作组,动作会被自动插入组中。
The action uses a stripped version of
text
(e.g. “&Menu Option…” becomes “Menu Option”) as descriptive text for tool buttons. You can override this by setting a specific description with
setText()
. The same text will be used for tooltips unless you specify a different text using
setToolTip()
.
PySide2.QtWidgets.QAction.
MenuRole
¶
此枚举描述应该如何把动作移入 macOS 应用程序菜单。
|
常量 |
描述 |
|---|---|
|
QAction.NoRole |
此动作不应放入应用程序菜单中 |
|
QAction.TextHeuristicRole |
This action should be put in the application menu based on the action’s text as described in the
|
|
QAction.ApplicationSpecificRole |
This action should be put in the application menu with an application specific role |
|
QAction.AboutQtRole |
This action handles the “About Qt” menu item. |
|
QAction.AboutRole |
This action should be placed where the “About” menu item is in the application menu. The text of the menu item will be set to “About <application name>”. The application name is fetched from the
|
|
QAction.PreferencesRole |
This action should be placed where the “Preferences…” menu item is in the application menu. |
|
QAction.QuitRole |
This action should be placed where the Quit menu item is in the application menu. |
Setting this value only has effect on items that are in the immediate menus of the menubar, not the submenus of those menus. For example, if you have File menu in your menubar and the File menu has a submenu, setting the for the actions in that submenu have no effect. They will never be moved.
PySide2.QtWidgets.QAction.
Priority
¶
此枚举定义用户界面中动作的优先级。
|
常量 |
描述 |
|---|---|
|
QAction.LowPriority |
动作不应该在用户界面中被优先。 |
|
QAction.NormalPriority |
|
|
QAction.HighPriority |
动作应该在用户界面中被优先。 |
另请参阅
priority
4.6 版新增。
PySide2.QtWidgets.QAction.
ActionEvent
¶
使用此枚举类型当调用
activate()
|
常量 |
描述 |
|---|---|
|
QAction.Trigger |
这将导致
|
|
QAction.Hover |
这将导致
|
PySide2.QtWidgets.QAction.
actionGroup
(
)
¶
返回此动作的动作组。返回 0 若没有动作组管理此动作。
另请参阅
QActionGroup
setActionGroup()
PySide2.QtWidgets.QAction.
activate
(
event
)
¶
event
–
ActionEvent
发送相关信号为
ActionEvent
event
.
基于动作的 Widget 使用此 API 以促使
QAction
去发射信号及发射它们自己。
PySide2.QtWidgets.QAction.
associatedGraphicsWidgets
(
)
¶
返回已添加此动作的小部件列表。
另请参阅
addAction()
associatedWidgets()
PySide2.QtWidgets.QAction.
associatedWidgets
(
)
¶
返回已添加此动作的小部件列表。
另请参阅
addAction()
associatedGraphicsWidgets()
PySide2.QtWidgets.QAction.
autoRepeat
(
)
¶
bool
另请参阅
setAutoRepeat()
PySide2.QtWidgets.QAction.
changed
(
)
¶
PySide2.QtWidgets.QAction.
data
(
)
¶
object
返回用户设置数据在
setData
.
另请参阅
setData()
PySide2.QtWidgets.QAction.
font
(
)
¶
QFont
另请参阅
setFont()
PySide2.QtWidgets.QAction.
hover
(
)
¶
这是调用 activate(Hover) 的方便槽。
PySide2.QtWidgets.QAction.
hovered
(
)
¶
PySide2.QtWidgets.QAction.
icon
(
)
¶
QIcon
另请参阅
setIcon()
PySide2.QtWidgets.QAction.
iconText
(
)
¶
unicode
另请参阅
setIconText()
PySide2.QtWidgets.QAction.
isCheckable
(
)
¶
bool
PySide2.QtWidgets.QAction.
isChecked
(
)
¶
bool
PySide2.QtWidgets.QAction.
isEnabled
(
)
¶
bool
PySide2.QtWidgets.QAction.
isIconVisibleInMenu
(
)
¶
bool
PySide2.QtWidgets.QAction.
isSeparator
(
)
¶
bool
返回
true
若此动作是分隔符动作;否则它返回
false
.
另请参阅
setSeparator()
PySide2.QtWidgets.QAction.
isShortcutVisibleInContextMenu
(
)
¶
bool
PySide2.QtWidgets.QAction.
isVisible
(
)
¶
bool
返回由此动作包含的菜单。包含菜单的动作可以被用于创建带子菜单的菜单项,或被插入工具栏中以创建带弹出菜单的按钮。
另请参阅
setMenu()
addAction()
另请参阅
setMenuRole()
PySide2.QtWidgets.QAction.
setActionGroup
(
group
)
¶
group
–
QActionGroup
把此动作组设为
group
. The action will be automatically added to the group’s list of actions.
组内动作将是相互排斥的。
另请参阅
QActionGroup
actionGroup()
PySide2.QtWidgets.QAction.
setAutoRepeat
(
arg__1
)
¶
arg__1
–
bool
另请参阅
autoRepeat()
PySide2.QtWidgets.QAction.
setCheckable
(
arg__1
)
¶
arg__1
–
bool
另请参阅
isCheckable()
PySide2.QtWidgets.QAction.
setChecked
(
arg__1
)
¶
arg__1
–
bool
另请参阅
isChecked()
PySide2.QtWidgets.QAction.
setData
(
var
)
¶
var – object
Sets the action’s internal data to the given
userData
.
另请参阅
data()
PySide2.QtWidgets.QAction.
setDisabled
(
b
)
¶
b
–
bool
这是方便函数,为
enabled
property, that is useful for signals–slots connections. If
b
is true the action is disabled; otherwise it is enabled.
PySide2.QtWidgets.QAction.
setEnabled
(
arg__1
)
¶
arg__1
–
bool
另请参阅
isEnabled()
PySide2.QtWidgets.QAction.
setFont
(
font
)
¶
font
–
QFont
另请参阅
font()
PySide2.QtWidgets.QAction.
setIcon
(
icon
)
¶
icon
–
QIcon
另请参阅
icon()
PySide2.QtWidgets.QAction.
setIconText
(
text
)
¶
text – unicode
另请参阅
iconText()
PySide2.QtWidgets.QAction.
setIconVisibleInMenu
(
visible
)
¶
visible
–
bool
另请参阅
isIconVisibleInMenu()
PySide2.QtWidgets.QAction.
setSeparator
(
b
)
¶
b
–
bool
若
b
为 true,则此动作将被认为是分隔符。
如何表示分隔符从属插入其的 Widget。在大多数情况下,文本、子菜单及图标会被分隔符动作忽略。
另请参阅
isSeparator()
PySide2.QtWidgets.QAction.
setShortcut
(
shortcut
)
¶
shortcut
–
QKeySequence
另请参阅
shortcut()
PySide2.QtWidgets.QAction.
setShortcutContext
(
context
)
¶
context
–
ShortcutContext
另请参阅
shortcutContext()
PySide2.QtWidgets.QAction.
setShortcutVisibleInContextMenu
(
show
)
¶
show
–
bool
另请参阅
isShortcutVisibleInContextMenu()
PySide2.QtWidgets.QAction.
setShortcuts
(
arg__1
)
¶
arg__1
–
StandardKey
设置从属平台的快捷方式列表基于
key
. The result of calling this function will depend on the currently running platform. Note that more than one shortcut can assigned by this action. If only the primary shortcut is required, use
setShortcut
代替。
另请参阅
keyBindings()
PySide2.QtWidgets.QAction.
setShortcuts
(
shortcuts
)
¶
shortcuts –
PySide2.QtWidgets.QAction.
setStatusTip
(
statusTip
)
¶
statusTip – unicode
另请参阅
statusTip()
PySide2.QtWidgets.QAction.
setText
(
text
)
¶
text – unicode
另请参阅
text()
PySide2.QtWidgets.QAction.
setToolTip
(
tip
)
¶
tip – unicode
另请参阅
toolTip()
PySide2.QtWidgets.QAction.
setVisible
(
arg__1
)
¶
arg__1
–
bool
另请参阅
isVisible()
PySide2.QtWidgets.QAction.
setWhatsThis
(
what
)
¶
what – unicode
另请参阅
whatsThis()
PySide2.QtWidgets.QAction.
shortcut
(
)
¶
QKeySequence
返回首要快捷键。
另请参阅
setShortcuts()
PySide2.QtWidgets.QAction.
shortcutContext
(
)
¶
ShortcutContext
另请参阅
setShortcutContext()
PySide2.QtWidgets.QAction.
shortcuts
(
)
¶
返回快捷键列表,采用首要快捷键作为列表的第一元素。
另请参阅
setShortcuts()
PySide2.QtWidgets.QAction.
showStatusText
(
[
widget=None
]
)
¶
widget
–
QWidget
bool
更新相关状态栏为
widget
指定通过发送
QStatusTipEvent
到其父级 Widget。返回
true
若事件被发送;否则返回
false
.
If a null widget is specified, the event is sent to the action’s parent.
另请参阅
statusTip
PySide2.QtWidgets.QAction.
statusTip
(
)
¶
unicode
另请参阅
setStatusTip()
PySide2.QtWidgets.QAction.
text
(
)
¶
unicode
另请参阅
setText()
PySide2.QtWidgets.QAction.
toggle
(
)
¶
这是方便函数,为
checked
property. Connect to it to change the checked state to its opposite state.
PySide2.QtWidgets.QAction.
toggled
(
arg__1
)
¶
arg__1
–
bool
PySide2.QtWidgets.QAction.
toolTip
(
)
¶
unicode
另请参阅
setToolTip()
PySide2.QtWidgets.QAction.
trigger
(
)
¶
这是调用 activate(Trigger) 的方便槽。
PySide2.QtWidgets.QAction.
triggered
(
[
checked=false
]
)
¶
checked
–
bool
PySide2.QtWidgets.QAction.
whatsThis
(
)
¶
unicode
另请参阅
setWhatsThis()