QSplitterHandleclass provides handle functionality for the splitter. 更多 …
def
closestLegalPosition
(p)
def
moveSplitter
(p)
def
opaqueResize
()
def
orientation
()
def
setOrientation
(o)
def
splitter
()
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 aboutQSplitterHandle. 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 reimplementcreateHandle()to instantiate the custom splitter handle. For example, a minimumQSplittersubclass might look like this:class Splitter(QSplitter): def __init__(self, orientation, parent): ... def createHandle(self): ... }
createHandle()implementation simply constructs a custom splitter handle, calledSplitterin this example:QSplitterHandle *Splitter::createHandle() { return new SplitterHandle(orientation(), this); }Information about a given handle can be obtained using functions like
orientation()andopaqueResize(), 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:void SplitterHandle::paintEvent(QPaintEvent *event) { QPainter painter(this); 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 ofsizeHint()unless the handle has special size requirements.另请参阅
QSplitterHandle
(
o
,
parent
)
¶
- param parent
- param o
取向
创建
QSplitter
handle with the given
orientation
and
parent
.
PySide2.QtWidgets.QSplitterHandle.
closestLegalPosition
(
p
)
¶
p
–
int
int
Returns the closest legal position to
pos
of the splitter handle. The positions are measured from the left or top edge of the splitter, even for right-to-left languages.
PySide2.QtWidgets.QSplitterHandle.
moveSplitter
(
p
)
¶
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.
注意:
pos
is also measured from the left (or top) for right-to-left languages. This function will map
pos
to the appropriate position before calling
moveSplitter()
.
PySide2.QtWidgets.QSplitterHandle.
opaqueResize
(
)
¶
bool
返回
true
若动态 (不透明) 重置 Widget 尺寸当交互移动分割器时。否则返回
false
. This value is controlled by the
QSplitter
.
另请参阅
PySide2.QtWidgets.QSplitterHandle.
orientation
(
)
¶
取向
Returns the handle’s orientation. This is usually propagated from the
QSplitter
.