• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QButtonGroup

    下一话题

    QAction

    QActionGroup

    概要

    函数

    信号

    详细描述

    PySide.QtGui.QActionGroup class groups actions together.

    In some situations it is useful to group PySide.QtGui.QAction objects together. For example, if you have a Left Align action, a Right Align action, a Justify action, and a Center action, only one of these actions should be active at any one time. One simple way of achieving this is to group the actions together in an action group.

    Here's a example (from the 菜单 范例):

    alignmentGroup =  QActionGroup(self)
    alignmentGroup.addAction(leftAlignAct)
    alignmentGroup.addAction(rightAlignAct)
    alignmentGroup.addAction(justifyAct)
    alignmentGroup.addAction(centerAct)
    leftAlignAct.setChecked(True)
    										

    Here we create a new action group. Since the action group is exclusive by default, only one of the actions in the group is checked at any one time.

    ../../_images/qactiongroup-align.png

    A PySide.QtGui.QActionGroup emits an PySide.QtGui.QActionGroup.triggered() signal when one of its actions is chosen. Each action in an action group emits its PySide.QtGui.QActionGroup.triggered() signal as usual.

    As stated above, an action group is exclusive() by default; it ensures that only one checkable action is active at any one time. If you want to group checkable actions without making them exclusive, you can turn of exclusiveness by calling setExclusive(false).

    Actions can be added to an action group using PySide.QtGui.QActionGroup.addAction() , but it is usually more convenient to specify a group when creating actions; this ensures that actions are automatically created with a parent. Actions can be visually separated from each other by adding a separator action to the group; create an action and use PySide.QtGui.QAction ‘s PySide.QtGui.QAction.setSeparator() function to make it considered a separator. Action groups are added to widgets with the QWidget.addActions() 函数。

    class PySide.QtGui. QActionGroup ( parent )
    参数: parent PySide.QtCore.QObject

    Constructs an action group for the parent 对象。

    The action group is exclusive by default. Call setExclusive(false) to make the action group non-exclusive.

    PySide.QtGui.QActionGroup. actions ( )
    返回类型:

    Returns the list of this groups's actions. This may be empty.

    PySide.QtGui.QActionGroup. addAction ( text )
    参数: text – unicode
    返回类型: PySide.QtGui.QAction

    Creates and returns an action with text . The newly created action is a child of this action group.

    Normally an action is added to a group by creating it with the group as parent, so this function is not usually used.

    PySide.QtGui.QActionGroup. addAction ( a )
    参数: a PySide.QtGui.QAction
    返回类型: PySide.QtGui.QAction

    添加 action to this group, and returns it.

    Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.

    PySide.QtGui.QActionGroup. addAction ( icon , text )
    参数:
    返回类型:

    PySide.QtGui.QAction

    Creates and returns an action with text icon . The newly created action is a child of this action group.

    Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.

    PySide.QtGui.QActionGroup. checkedAction ( )
    返回类型: PySide.QtGui.QAction

    Returns the currently checked action in the group, or 0 if none are checked.

    PySide.QtGui.QActionGroup. hovered ( arg__1 )
    参数: arg__1 PySide.QtGui.QAction
    PySide.QtGui.QActionGroup. isEnabled ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the action group is enabled.

    Each action in the group will be enabled or disabled unless it has been explicitly disabled.

    PySide.QtGui.QActionGroup. isExclusive ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the action group does exclusive checking.

    If exclusive is true, only one checkable action in the action group can ever be active at any time. If the user chooses another checkable action in the group, the one they chose becomes active and the one that was active becomes inactive.

    另请参阅

    QAction.checkable

    PySide.QtGui.QActionGroup. isVisible ( )
    返回类型: PySide.QtCore.bool

    This property holds whether the action group is visible.

    Each action in the action group will match the visible state of this group unless it has been explicitly hidden.

    PySide.QtGui.QActionGroup. removeAction ( a )
    参数: a PySide.QtGui.QAction

    移除 action from this group. The action will have no parent as a result.

    PySide.QtGui.QActionGroup. setDisabled ( b )
    参数: b PySide.QtCore.bool

    这是方便函数,为 enabled() property, that is useful for signals–slots connections. If b is true the action group is disabled; otherwise it is enabled.

    PySide.QtGui.QActionGroup. setEnabled ( arg__1 )
    参数: arg__1 PySide.QtCore.bool

    This property holds whether the action group is enabled.

    Each action in the group will be enabled or disabled unless it has been explicitly disabled.

    PySide.QtGui.QActionGroup. setExclusive ( arg__1 )
    参数: arg__1 PySide.QtCore.bool

    This property holds whether the action group does exclusive checking.

    If exclusive is true, only one checkable action in the action group can ever be active at any time. If the user chooses another checkable action in the group, the one they chose becomes active and the one that was active becomes inactive.

    另请参阅

    QAction.checkable

    PySide.QtGui.QActionGroup. setVisible ( arg__1 )
    参数: arg__1 PySide.QtCore.bool

    This property holds whether the action group is visible.

    Each action in the action group will match the visible state of this group unless it has been explicitly hidden.

    PySide.QtGui.QActionGroup. triggered ( arg__1 )
    参数: arg__1 PySide.QtGui.QAction