QSplitter

Inheritance diagram of QSplitter

Synopsis

Functions

Virtual functions

Signals

Detailed Description

The 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() .

The following example will show a PySide.QtGui.QListView , PySide.QtGui.QTreeView , and PySide.QtGui.QTextEdit side by side, with two splitter handles:

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() , and 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() (or 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 using PySide.QtGui.QSplitter.saveState() and PySide.QtGui.QSplitter.restoreState() respectively.

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])
Parameters:

Constructs a horizontal splitter with the parent arguments is passed on to the PySide.QtGui.QFrame constructor.

PySide.QtGui.QSplitter.addWidget(widget)
Parameters:widgetPySide.QtGui.QWidget

Adds the given widget to the splitter’s layout after all the other items.

If widget is already in the splitter, it will be moved to the new position.

PySide.QtGui.QSplitter.childrenCollapsible()
Return type: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)
Parameters:
  • arg__1PySide.QtCore.int
  • arg__2PySide.QtCore.int
Return type:

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()
Return type:PySide.QtCore.int

Returns the number of widgets contained in the splitter’s layout.

PySide.QtGui.QSplitter.createHandle()
Return type: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)
Parameters:indexPySide.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)
Parameters:indexPySide.QtCore.int
Return type: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()
Return type: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)
Parameters:wPySide.QtGui.QWidget
Return type: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)
Parameters:

Inserts the widget specified into the splitter’s layout at the given index .

If widget is already in the splitter, it will be moved to the new position.

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

PySide.QtGui.QSplitter.isCollapsible(index)
Parameters:indexPySide.QtCore.int
Return type:PySide.QtCore.bool

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

PySide.QtGui.QSplitter.moveSplitter(pos, index)
Parameters:
  • posPySide.QtCore.int
  • indexPySide.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()
Return type:PySide.QtCore.bool

This property holds whether resizing is opaque.

Opaque resizing is on by default.

PySide.QtGui.QSplitter.orientation()
Return type: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)
Parameters:statePySide.QtCore.QByteArray
Return type:PySide.QtCore.bool

Restores the splitter’s layout to the state specified. Returns true if the state is restored; otherwise returns false.

Typically this is used in conjunction with PySide.QtCore.QSettings to restore the size from a past session. Here is an example:

Restore the splitters’s state:

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

A failure to restore the splitter’s layout may result from either invalid or out-of-date data in the supplied byte array.

PySide.QtGui.QSplitter.saveState()
Return type:PySide.QtCore.QByteArray

Saves the state of the splitter’s layout.

Typically this is used in conjunction with PySide.QtCore.QSettings to remember the size for a future session. A version number is stored as part of the data. Here is an example:

settings = QSettings()
settings.setValue("splitterSizes", splitter.saveState())
PySide.QtGui.QSplitter.setChildrenCollapsible(arg__1)
Parameters:arg__1PySide.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)
Parameters:
  • indexPySide.QtCore.int
  • arg__2PySide.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() property.

PySide.QtGui.QSplitter.setHandleWidth(arg__1)
Parameters:arg__1PySide.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])
Parameters:opaquePySide.QtCore.bool

This property holds whether resizing is opaque.

Opaque resizing is on by default.

PySide.QtGui.QSplitter.setOrientation(arg__1)
Parameters:arg__1PySide.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)
Parameters:positionPySide.QtCore.int

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

PySide.QtGui.QSplitter.setSizes(list)
Parameters:list
PySide.QtGui.QSplitter.setStretchFactor(index, stretch)
Parameters:
  • indexPySide.QtCore.int
  • stretchPySide.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()
Return type:

Returns a list of the size parameters of all the widgets in this splitter.

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.

Giving the values to another splitter’s PySide.QtGui.QSplitter.setSizes() function will produce a splitter with the same layout as this one.

Note that invisible widgets have a size of 0.

PySide.QtGui.QSplitter.splitterMoved(pos, index)
Parameters:
  • posPySide.QtCore.int
  • indexPySide.QtCore.int
PySide.QtGui.QSplitter.widget(index)
Parameters:indexPySide.QtCore.int
Return type:PySide.QtGui.QWidget

Returns the widget at the given index in the splitter’s layout.