本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.handleWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.handleWidth方法的具体用法?Python QSplitter.handleWidth怎么用?Python QSplitter.handleWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.handleWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QuadView
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import handleWidth [as 别名]
class QuadView(QWidget):
def __init__(self, parent, view1, view2, view3, view4=None):
QWidget.__init__(self, parent)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.installEventFilter(self)
self.dockableContainer = []
self.layout = QVBoxLayout()
self.setLayout(self.layout)
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.splitVertical = QSplitter(Qt.Vertical, self)
self.layout.addWidget(self.splitVertical)
self.splitHorizontal1 = QSplitter(Qt.Horizontal, self.splitVertical)
self.splitHorizontal1.setObjectName("splitter1")
self.splitHorizontal2 = QSplitter(Qt.Horizontal, self.splitVertical)
self.splitHorizontal2.setObjectName("splitter2")
self.splitHorizontal1.splitterMoved.connect(self.horizontalSplitterMoved)
self.splitHorizontal2.splitterMoved.connect(self.horizontalSplitterMoved)
self.imageView2D_1 = view1
self.imageView2D_2 = view2
self.imageView2D_3 = view3
self.dock1_ofSplitHorizontal1 = ImageView2DDockWidget(self.imageView2D_1)
self.dock1_ofSplitHorizontal1.connectHud()
self.dockableContainer.append(self.dock1_ofSplitHorizontal1)
self.dock1_ofSplitHorizontal1.onDockButtonClicked.connect(
lambda arg=self.dock1_ofSplitHorizontal1: self.on_dock(arg)
)
self.dock1_ofSplitHorizontal1.onMaxButtonClicked.connect(
lambda arg=self.dock1_ofSplitHorizontal1: self.on_max(arg)
)
self.dock1_ofSplitHorizontal1.onMinButtonClicked.connect(
lambda arg=self.dock1_ofSplitHorizontal1: self.on_min(arg)
)
self.splitHorizontal1.addWidget(self.dock1_ofSplitHorizontal1)
self.dock2_ofSplitHorizontal1 = ImageView2DDockWidget(self.imageView2D_2)
self.dock2_ofSplitHorizontal1.onDockButtonClicked.connect(
lambda arg=self.dock2_ofSplitHorizontal1: self.on_dock(arg)
)
self.dock2_ofSplitHorizontal1.onMaxButtonClicked.connect(
lambda arg=self.dock2_ofSplitHorizontal1: self.on_max(arg)
)
self.dock2_ofSplitHorizontal1.onMinButtonClicked.connect(
lambda arg=self.dock2_ofSplitHorizontal1: self.on_min(arg)
)
self.dock2_ofSplitHorizontal1.connectHud()
self.dockableContainer.append(self.dock2_ofSplitHorizontal1)
self.splitHorizontal1.addWidget(self.dock2_ofSplitHorizontal1)
self.dock1_ofSplitHorizontal2 = ImageView2DDockWidget(self.imageView2D_3)
self.dock1_ofSplitHorizontal2.onDockButtonClicked.connect(
lambda arg=self.dock1_ofSplitHorizontal2: self.on_dock(arg)
)
self.dock1_ofSplitHorizontal2.onMaxButtonClicked.connect(
lambda arg=self.dock1_ofSplitHorizontal2: self.on_max(arg)
)
self.dock1_ofSplitHorizontal2.onMinButtonClicked.connect(
lambda arg=self.dock1_ofSplitHorizontal2: self.on_min(arg)
)
self.dock1_ofSplitHorizontal2.connectHud()
self.dockableContainer.append(self.dock1_ofSplitHorizontal2)
self.splitHorizontal2.addWidget(self.dock1_ofSplitHorizontal2)
self.dock2_ofSplitHorizontal2 = ImageView2DDockWidget(view4)
self.dockableContainer.append(self.dock2_ofSplitHorizontal2)
self.splitHorizontal2.addWidget(self.dock2_ofSplitHorizontal2)
# this is a hack: with 0 ms it does not work...
QTimer.singleShot(250, self._resizeEqual)
def _resizeEqual(self):
if not all([dock.isVisible() for dock in self.dockableContainer]):
return
w, h = (
self.size().width() - self.splitHorizontal1.handleWidth(),
self.size().height() - self.splitVertical.handleWidth(),
)
self.splitVertical.setSizes([h // 2, h // 2])
if self.splitHorizontal1.count() == 2 and self.splitHorizontal2.count() == 2:
# docks = [self.imageView2D_1, self.imageView2D_2, self.imageView2D_3, self.testView4]
docks = []
for splitter in [self.splitHorizontal1, self.splitHorizontal2]:
for i in range(splitter.count()):
docks.append(splitter.widget(i).graphicsView)
w1 = [docks[i].minimumSize().width() for i in [0, 2]]
w2 = [docks[i].minimumSize().width() for i in [1, 3]]
wLeft = max(w1)
wRight = max(w2)
#.........这里部分代码省略.........