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

    上一话题

    QDial

    下一话题

    QAbstractSpinBox

    QSplitter

    概要

    函数

    虚函数

    信号

    详细描述

    PySide.QtGui.QSplitter class implements a splitter widget.

    A splitter lets the user control the size of child widgets by dragging the boundary between the children. Any number of widgets may be controlled by a single splitter. The typical use of a PySide.QtGui.QSplitter is to create several widgets and add them using PySide.QtGui.QSplitter.insertWidget() or PySide.QtGui.QSplitter.addWidget() .

    以下范例将展示 PySide.QtGui.QListView , PySide.QtGui.QTreeView ,和 PySide.QtGui.QTextEdit 并排,采用 2 个分割器手柄:

    splitter =  QSplitter(parent)
    listview =  QListView()
    treeview =  QTreeView()
    textedit =  QTextEdit()
    splitter.addWidget(listview)
    splitter.addWidget(treeview)
    splitter.addWidget(textedit)
    										

    If a widget is already inside a PySide.QtGui.QSplitter when PySide.QtGui.QSplitter.insertWidget() or PySide.QtGui.QSplitter.addWidget() is called, it will move to the new position. This can be used to reorder widgets in the splitter later. You can use PySide.QtGui.QSplitter.indexOf() , PySide.QtGui.QSplitter.widget() ,和 PySide.QtGui.QSplitter.count() to get access to the widgets inside the splitter.

    A default PySide.QtGui.QSplitter lays out its children horizontally (side by side); you can use setOrientation( Qt.Vertical ) to lay its children out vertically.

    By default, all widgets can be as large or as small as the user wishes, between the PySide.QtGui.QSplitter.minimumSizeHint() (或 PySide.QtGui.QWidget.minimumSize() ) and PySide.QtGui.QWidget.maximumSize() of the widgets.

    PySide.QtGui.QSplitter resizes its children dynamically by default. If you would rather have PySide.QtGui.QSplitter resize the children only at the end of a resize operation, call setOpaqueResize(false).

    The initial distribution of size between the widgets is determined by multiplying the initial size with the stretch factor. You can also use PySide.QtGui.QSplitter.setSizes() to set the sizes of all the widgets. The function PySide.QtGui.QSplitter.sizes() returns the sizes set by the user. Alternatively, you can save and restore the sizes of the widgets from a PySide.QtCore.QByteArray 使用 PySide.QtGui.QSplitter.saveState() and PySide.QtGui.QSplitter.restoreState() 分别。

    When you PySide.QtGui.QWidget.hide() a child its space will be distributed among the other children. It will be reinstated when you PySide.QtGui.QWidget.show() it again.

    class PySide.QtGui. QSplitter ( [ parent=None ] )
    class PySide.QtGui. QSplitter ( arg__1 [ , parent=None ] )
    参数:

    构造水平分割器采用 parent argument passed on to the PySide.QtGui.QFrame 构造函数。

    PySide.QtGui.QSplitter. addWidget ( widget )
    参数: widget PySide.QtGui.QWidget

    添加给定 widget 到分割器布局在所有其它项之后。

    widget 已在分割器中,它将被移动到新位置。

    PySide.QtGui.QSplitter. childrenCollapsible ( )
    返回类型: PySide.QtCore.bool

    This property holds whether child widgets can be resized down to size 0 by the user.

    By default, children are collapsible. It is possible to enable and disable the collapsing of individual children using PySide.QtGui.QSplitter.setCollapsible() .

    PySide.QtGui.QSplitter. closestLegalPosition ( arg__1 , arg__2 )
    参数:
    • arg__1 PySide.QtCore.int
    • arg__2 PySide.QtCore.int
    返回类型:

    PySide.QtCore.int

    Returns the closest legal position to pos of the widget with index index .

    For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. Positions are then measured from the right edge of the widget.

    PySide.QtGui.QSplitter. count ( )
    返回类型: PySide.QtCore.int

    返回分割器布局所包含的 Widget 数。

    PySide.QtGui.QSplitter. createHandle ( )
    返回类型: PySide.QtGui.QSplitterHandle

    Returns a new splitter handle as a child widget of this splitter. This function can be reimplemented in subclasses to provide support for custom handles.

    PySide.QtGui.QSplitter. getRange ( index )
    参数: index PySide.QtCore.int

    Returns the valid range of the splitter with index index in *``min`` and *``max`` if min and max are not 0.

    PySide.QtGui.QSplitter. handle ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtGui.QSplitterHandle

    Returns the handle to the left (or above) for the item in the splitter's layout at the given index . The handle at index 0 is always hidden.

    For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. The handle will be to the right of the widget at index .

    PySide.QtGui.QSplitter. handleWidth ( )
    返回类型: PySide.QtCore.int

    This property holds the width of the splitter handles.

    By default, this property contains a value that depends on the user's platform and style preferences.

    If you set PySide.QtGui.QSplitter.handleWidth() to 1, the actual grab area will grow to overlap a few pixels of it's respective widgets.

    PySide.QtGui.QSplitter. indexOf ( w )
    参数: w PySide.QtGui.QWidget
    返回类型: PySide.QtCore.int

    Returns the index in the splitter's layout of the specified widget . This also works for handles.

    Handles are numbered from 0. There are as many handles as there are child widgets, but the handle at position 0 is always hidden.

    PySide.QtGui.QSplitter. insertWidget ( index , widget )
    参数:

    插入 widget specified into the splitter's layout at the given index .

    widget 已在分割器中,它将被移动到新位置。

    if index is an invalid index, then the widget will be inserted at the end.

    PySide.QtGui.QSplitter. isCollapsible ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.bool

    Returns true if the widget at index is collapsible, otherwise returns false

    PySide.QtGui.QSplitter. moveSplitter ( pos , index )
    参数:
    • pos PySide.QtCore.int
    • index PySide.QtCore.int

    Moves the left or top edge of the splitter handle at index as close as possible to position pos , which is the distance from the left or top edge of the widget.

    For right-to-left languages such as Arabic and Hebrew, the layout of horizontal splitters is reversed. pos is then the distance from the right edge of the widget.

    PySide.QtGui.QSplitter. opaqueResize ( )
    返回类型: PySide.QtCore.bool

    This property holds whether resizing is opaque.

    Opaque resizing is on by default.

    PySide.QtGui.QSplitter. orientation ( )
    返回类型: PySide.QtCore.Qt.Orientation

    This property holds the orientation of the splitter.

    By default the orientation is horizontal (i.e., the widgets are laid out side by side). The possible orientations are Qt.Horizontal and Qt.Vertical .

    PySide.QtGui.QSplitter. refresh ( )

    Updates the splitter's state. You should not need to call this function.

    PySide.QtGui.QSplitter. restoreState ( state )
    参数: state PySide.QtCore.QByteArray
    返回类型: PySide.QtCore.bool

    将分割器布局还原成 state specified. Returns true if the state is restored; otherwise returns false.

    通常,这用于结合 PySide.QtCore.QSettings 从过去的会话还原尺寸。这里是范例:

    Restore the splitters's state:

    settings = QSettings()
    splitter.restoreState(settings.value("splitterSizes").toByteArray())
    											

    所提供的字节数组中的数据,无效或过期可能导致无法还原分割器布局。

    PySide.QtGui.QSplitter. saveState ( )
    返回类型: PySide.QtCore.QByteArray

    保存分割器布局的状态。

    通常,这用于结合 PySide.QtCore.QSettings 以记住用于未来会议的尺寸。版本号作为数据的一部分被存储。这里是范例:

    settings = QSettings()
    settings.setValue("splitterSizes", splitter.saveState())
    											
    PySide.QtGui.QSplitter. setChildrenCollapsible ( arg__1 )
    参数: arg__1 PySide.QtCore.bool

    This property holds whether child widgets can be resized down to size 0 by the user.

    By default, children are collapsible. It is possible to enable and disable the collapsing of individual children using PySide.QtGui.QSplitter.setCollapsible() .

    PySide.QtGui.QSplitter. setCollapsible ( index , arg__2 )
    参数:
    • index PySide.QtCore.int
    • arg__2 PySide.QtCore.bool

    Sets whether the child widget at index index is collapsible to collapse .

    By default, children are collapsible, meaning that the user can resize them down to size 0, even if they have a non-zero PySide.QtGui.QWidget.minimumSize() or PySide.QtGui.QSplitter.minimumSizeHint() . This behavior can be changed on a per-widget basis by calling this function, or globally for all the widgets in the splitter by setting the PySide.QtGui.QSplitter.childrenCollapsible() 特性。

    PySide.QtGui.QSplitter. setHandleWidth ( arg__1 )
    参数: arg__1 PySide.QtCore.int

    This property holds the width of the splitter handles.

    By default, this property contains a value that depends on the user's platform and style preferences.

    If you set PySide.QtGui.QSplitter.handleWidth() to 1, the actual grab area will grow to overlap a few pixels of it's respective widgets.

    PySide.QtGui.QSplitter. setOpaqueResize ( [ opaque=true ] )
    参数: opaque PySide.QtCore.bool

    This property holds whether resizing is opaque.

    Opaque resizing is on by default.

    PySide.QtGui.QSplitter. setOrientation ( arg__1 )
    参数: arg__1 PySide.QtCore.Qt.Orientation

    This property holds the orientation of the splitter.

    By default the orientation is horizontal (i.e., the widgets are laid out side by side). The possible orientations are Qt.Horizontal and Qt.Vertical .

    PySide.QtGui.QSplitter. setRubberBand ( position )
    参数: position PySide.QtCore.int

    Displays a rubber band at position pos 。若 pos is negative, the rubber band is removed.

    PySide.QtGui.QSplitter. setSizes ( list )
    参数: list
    PySide.QtGui.QSplitter. setStretchFactor ( index , stretch )
    参数:
    • index PySide.QtCore.int
    • stretch PySide.QtCore.int

    Updates the size policy of the widget at position index to have a stretch factor of stretch .

    stretch is not the effective stretch factor; the effective stretch factor is calculated by taking the initial size of the widget and multiplying it with stretch .

    This function is provided for convenience. It is equivalent to

    widget = splitter.widget(index)
    policy = widget.sizePolicy()
    policy.setHorizontalStretch(stretch)
    policy.setVerticalStretch(stretch)
    widget.setSizePolicy(policy)
    											
    PySide.QtGui.QSplitter. sizes ( )
    返回类型:

    返回此分割器所有 Widget 尺寸的参数列表。

    If the splitter's orientation is horizontal, the list contains the widgets width in pixels, from left to right; if the orientation is vertical, the list contains the widgets height in pixels, from top to bottom.

    将值赋予另一分割器的 PySide.QtGui.QSplitter.setSizes() function will produce a splitter with the same layout as this one.

    注意:不可见 Widget 拥有 0 尺寸。

    PySide.QtGui.QSplitter. splitterMoved ( pos , index )
    参数:
    • pos PySide.QtCore.int
    • index PySide.QtCore.int
    PySide.QtGui.QSplitter. widget ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtGui.QWidget

    返回 Widget 在给定 index in the splitter's layout.