本文整理汇总了Python中PyQt4.QtCore.QSize.boundedTo方法的典型用法代码示例。如果您正苦于以下问题:Python QSize.boundedTo方法的具体用法?Python QSize.boundedTo怎么用?Python QSize.boundedTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QSize
的用法示例。
在下文中一共展示了QSize.boundedTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sizeHint
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import boundedTo [as 别名]
def sizeHint(self):
""" Get the size hint for the scroll area.
This reimplemented method fixes a Qt bug where the size hint
is not updated after the scroll widget is first shown. The
bug is documented on the Qt bug tracker:
https://bugreports.qt-project.org/browse/QTBUG-10545
"""
# This code is ported directly from QScrollArea.cpp but instead
# of caching the size hint of the scroll widget, it caches the
# size hint for the entire scroll area, and invalidates it when
# the widget is changed or it receives a LayoutRequest event.
hint = self._size_hint
if hint.isValid():
return QSize(hint)
fw = 2 * self.frameWidth()
hint = QSize(fw, fw)
font_height = self.fontMetrics().height()
widget = self.widget()
if widget is not None:
if self.widgetResizable():
hint += widget.sizeHint()
else:
hint += widget.size()
else:
hint += QSize(12 * font_height, 8 * font_height)
if self.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOn:
vbar = self.verticalScrollBar()
hint.setWidth(hint.width() + vbar.sizeHint().width())
if self.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOn:
hbar = self.horizontalScrollBar()
hint.setHeight(hint.height() + hbar.sizeHint().height())
hint = hint.boundedTo(QSize(36 * font_height, 24 * font_height))
self._size_hint = hint
return QSize(hint)