本文整理汇总了Python中AnyQt.QtWidgets.QVBoxLayout.invalidate方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.invalidate方法的具体用法?Python QVBoxLayout.invalidate怎么用?Python QVBoxLayout.invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.invalidate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToolBox
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import invalidate [as 别名]
#.........这里部分代码省略.........
return button
def ensureWidgetVisible(self, child, xmargin=50, ymargin=50):
"""
Scroll the contents so child widget instance is visible inside
the viewport.
"""
self.__scrollArea.ensureWidgetVisible(child, xmargin, ymargin)
def sizeHint(self):
hint = self.__contentsLayout.sizeHint()
if self.count():
# Compute max width of hidden widgets also.
scroll = self.__scrollArea
scroll_w = scroll.verticalScrollBar().sizeHint().width()
frame_w = self.frameWidth() * 2 + scroll.frameWidth() * 2
max_w = max([p.widget.sizeHint().width() for p in self.__pages])
hint = QSize(max(max_w, hint.width()) + scroll_w + frame_w,
hint.height())
return QSize(200, 200).expandedTo(hint)
def __onTabActionToogled(self, action):
page = find(self.__pages, action, key=attrgetter("action"))
on = action.isChecked()
page.widget.setVisible(on)
index = page.index
if index > 0:
# Update the `previous` tab buttons style hints
previous = self.__pages[index - 1].button
flag = QStyleOptionToolBox.NextIsSelected
if on:
previous.selected |= flag
else:
previous.selected &= ~flag
previous.update()
if index < self.count() - 1:
next = self.__pages[index + 1].button
flag = QStyleOptionToolBox.PreviousIsSelected
if on:
next.selected |= flag
else:
next.selected &= ~flag
next.update()
self.tabToogled.emit(index, on)
self.__contentsLayout.invalidate()
def __updateSelected(self):
"""Update the tab buttons selected style flags.
"""
if self.count() == 0:
return
opt = QStyleOptionToolBox
def update(button, next_sel, prev_sel):
if next_sel:
button.selected |= opt.NextIsSelected
else:
button.selected &= ~opt.NextIsSelected
if prev_sel:
button.selected |= opt.PreviousIsSelected
else:
button.selected &= ~ opt.PreviousIsSelected
button.update()
if self.count() == 1:
update(self.__pages[0].button, False, False)
elif self.count() >= 2:
pages = self.__pages
for i in range(1, self.count() - 1):
update(pages[i].button,
pages[i + 1].action.isChecked(),
pages[i - 1].action.isChecked())
def __updatePositions(self):
"""Update the tab buttons position style flags.
"""
if self.count() == 0:
return
elif self.count() == 1:
self.__pages[0].button.position = QStyleOptionToolBox.OnlyOneTab
else:
self.__pages[0].button.position = QStyleOptionToolBox.Beginning
self.__pages[-1].button.position = QStyleOptionToolBox.End
for p in self.__pages[1:-1]:
p.button.position = QStyleOptionToolBox.Middle
for p in self.__pages:
p.button.update()