本文整理汇总了Python中AnyQt.QtCore.QRect.contains方法的典型用法代码示例。如果您正苦于以下问题:Python QRect.contains方法的具体用法?Python QRect.contains怎么用?Python QRect.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRect
的用法示例。
在下文中一共展示了QRect.contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __autoScrollAdvance
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import contains [as 别名]
def __autoScrollAdvance(self):
"""Advance the auto scroll
"""
pos = QCursor.pos()
pos = self.mapFromGlobal(pos)
margin = self.__autoScrollMargin
vvalue = self.verticalScrollBar().value()
hvalue = self.horizontalScrollBar().value()
vrect = QRect(0, 0, self.width(), self.height())
# What should be the speed
advance = 10
# We only do auto scroll if the mouse is inside the view.
if vrect.contains(pos):
if pos.x() < vrect.left() + margin:
self.horizontalScrollBar().setValue(hvalue - advance)
if pos.y() < vrect.top() + margin:
self.verticalScrollBar().setValue(vvalue - advance)
if pos.x() > vrect.right() - margin:
self.horizontalScrollBar().setValue(hvalue + advance)
if pos.y() > vrect.bottom() - margin:
self.verticalScrollBar().setValue(vvalue + advance)
if self.verticalScrollBar().value() == vvalue and \
self.horizontalScrollBar().value() == hvalue:
self.__stopAutoScroll()
else:
self.__stopAutoScroll()
log.debug("Auto scroll advance")
示例2: testArrowContact
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import contains [as 别名]
def testArrowContact(self, indices, x, y):
if type(indices) != list: indices = [indices]
for index in indices:
if index >= len(self.attributes) or index < 0:
continue
int_x = self.transform(xBottom, index)
bottom = self.transform(yLeft,
self.selection_conditions.get(self.attributes[index], [0, 1])[0])
bottom_rect = QRect(int_x - self.bottom_pixmap.width() / 2, bottom, self.bottom_pixmap.width(),
self.bottom_pixmap.height())
if bottom_rect.contains(QPoint(x, y)):
return 1, (index, 0)
top = self.transform(yLeft,
self.selection_conditions.get(self.attributes[index], [0, 1])[1])
top_rect = QRect(int_x - self.top_pixmap.width() / 2, top - self.top_pixmap.height(),
self.top_pixmap.width(),
self.top_pixmap.height())
if top_rect.contains(QPoint(x, y)):
return 1, (index, 1)
return 0, (0, 0)