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.
| 参数: |
|
|---|
构造水平分割器采用 parent argument passed on to the PySide.QtGui.QFrame 构造函数。
| 参数: | widget – PySide.QtGui.QWidget |
|---|
添加给定 widget 到分割器布局在所有其它项之后。
若 widget 已在分割器中,它将被移动到新位置。
| 返回类型: | 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.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.QtCore.int |
|---|
返回分割器布局所包含的 Widget 数。
| 返回类型: | 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.
| 参数: | 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.
| 参数: | 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.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.
| 参数: | 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.
| 参数: |
|
|---|
插入 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.
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Returns true if the widget at index is collapsible, otherwise returns false
| 参数: |
|
|---|
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.QtCore.bool |
|---|
This property holds whether resizing is opaque.
Opaque resizing is on by default.
| 返回类型: | 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 .
Updates the splitter's state. You should not need to call this function.
| 参数: | 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.QtCore.QByteArray |
|---|
保存分割器布局的状态。
通常,这用于结合 PySide.QtCore.QSettings 以记住用于未来会议的尺寸。版本号作为数据的一部分被存储。这里是范例:
settings = QSettings()
settings.setValue("splitterSizes", splitter.saveState())
| 参数: | 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() .
| 参数: |
|
|---|
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() 特性。
| 参数: | 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.
| 参数: | opaque – PySide.QtCore.bool |
|---|
This property holds whether resizing is opaque.
Opaque resizing is on by default.
| 参数: | 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 .
| 参数: | position – PySide.QtCore.int |
|---|
Displays a rubber band at position pos 。若 pos is negative, the rubber band is removed.
| 参数: | list – |
|---|
| 参数: |
|
|---|
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)
| 返回类型: |
|---|
返回此分割器所有 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 尺寸。
| 参数: |
|
|---|
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QWidget |
返回 Widget 在给定 index in the splitter's layout.