PySide6.QtWidgets.QSplitterHandle¶
- class QSplitterHandle¶
- The - QSplitterHandleclass provides handle functionality for the splitter. More…- Synopsis¶- Methods¶- def - __init__()
- def - moveSplitter()
- def - opaqueResize()
- def - orientation()
- def - setOrientation()
- def - splitter()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - QSplitterHandleis typically what people think about when they think about a splitter. It is the handle that is used to resize the widgets.- A typical developer using - QSplitterwill never have to worry about- QSplitterHandle. It is provided for developers who want splitter handles that provide extra features, such as popup menus.- The typical way one would create splitter handles is to subclass - QSplitterand then reimplement- createHandle()to instantiate the custom splitter handle. For example, a minimum- QSplittersubclass might look like this:- class Splitter(QSplitter): # public Splitter(Qt.Orientation orientation, QWidget parent = None) # protected QSplitterHandle createHandle() override - The - createHandle()implementation simply constructs a custom splitter handle, called- Splitterin this example:- QSplitterHandle Splitter.createHandle() return SplitterHandle(orientation(), self) - Information about a given handle can be obtained using functions like - orientation()and- opaqueResize(), and is retrieved from its parent splitter. Details like these can be used to give custom handles different appearances depending on the splitter’s orientation.- The complexity of a custom handle subclass depends on the tasks that it needs to perform. A simple subclass might only provide a - paintEvent()implementation:- def paintEvent(self, event): painter = QPainter(self) if orientation() == Qt.Horizontal: gradient.setStart(rect().left(), rect().height()/2) gradient.setFinalStop(rect().right(), rect().height()/2) else: gradient.setStart(rect().width()/2, rect().top()) gradient.setFinalStop(rect().width()/2, rect().bottom()) painter.fillRect(event.rect(), QBrush(gradient)) - In this example, a predefined gradient is set up differently depending on the orientation of the handle. - QSplitterHandleprovides a reasonable size hint for the handle, so the subclass does not need to provide a reimplementation of- sizeHint()unless the handle has special size requirements.- See also - __init__(o, parent)¶
- Parameters:
- o – - Orientation
- parent – - QSplitter
 
 
 - Creates a - QSplitterhandle with the given- orientationand- parent.- closestLegalPosition(p)¶
- Parameters:
- p – int 
- Return type:
- int 
 
 - Returns the closest legal position to - posof the splitter handle. The positions are measured from the left or top edge of the splitter, even for right-to-left languages.- See also - moveSplitter(p)¶
- Parameters:
- p – int 
 
 - Tells the splitter to move this handle to position - pos, which is the distance from the left or top edge of the widget.- Note that - posis also measured from the left (or top) for right-to-left languages. This function will map- posto the appropriate position before calling- moveSplitter().- See also - opaqueResize()¶
- Return type:
- bool 
 
 - Returns - trueif widgets are resized dynamically (opaquely) while interactively moving the splitter. Otherwise returns- false. This value is controlled by the- QSplitter.- See also - orientation()¶
- Return type:
 
 - Returns the handle’s orientation. This is usually propagated from the - QSplitter.- See also - setOrientation(o)¶
- Parameters:
- o – - Orientation
 
 - Sets the orientation of the splitter handle to - orientation. This is usually propagated from the- QSplitter.- See also - Returns the splitter associated with this splitter handle. - See also