本文整理汇总了Python中AnyQt.QtCore.QRect.intersected方法的典型用法代码示例。如果您正苦于以下问题:Python QRect.intersected方法的具体用法?Python QRect.intersected怎么用?Python QRect.intersected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRect
的用法示例。
在下文中一共展示了QRect.intersected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dropdown_popup_geometry
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import intersected [as 别名]
def dropdown_popup_geometry(geometry, origin, screen):
# type: (QRect, QRect, QRect) -> QRect
"""
Move/constrain the geometry for a drop down popup.
Parameters
----------
geometry : QRect
The base popup geometry if not constrained.
origin : QRect
The origin rect from which the popup extends.
screen : QRect
The available screen geometry into which the popup must fit.
Returns
-------
geometry: QRect
Constrained drop down list geometry to fit into screen
"""
# if the popup geometry extends bellow the screen and there is more room
# above the popup origin ...
geometry = QRect(geometry)
geometry.moveTopLeft(origin.bottomLeft() + QPoint(0, 1))
if geometry.bottom() > screen.bottom() \
and origin.center().y() > screen.center().y():
# ...flip the rect about the origin so it extends upwards
geometry.moveBottom(origin.top() - 1)
# fixup horizontal position if it extends outside the screen
if geometry.left() < screen.left():
geometry.moveLeft(screen.left())
if geometry.right() > screen.right():
geometry.moveRight(screen.right())
# bounded by screen geometry
return geometry.intersected(screen)