本文整理汇总了Python中AnyQt.QtCore.QRect.top方法的典型用法代码示例。如果您正苦于以下问题:Python QRect.top方法的具体用法?Python QRect.top怎么用?Python QRect.top使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRect
的用法示例。
在下文中一共展示了QRect.top方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fitRect
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import top [as 别名]
def fitRect(rect, targetrect):
size = rect.size().boundedTo(targetgeom.size())
newrect = QRect(rect.topLeft(), size)
dx, dy = 0, 0
if newrect.left() < targetrect.left():
dx = targetrect.left() - newrect.left()
if newrect.top() < targetrect.top():
dy = targetrect.top() - newrect.top()
if newrect.right() > targetrect.right():
dx = targetrect.right() - newrect.right()
if newrect.bottom() > targetrect.bottom():
dy = targetrect.bottom() - newrect.bottom()
return newrect.translated(dx, dy)
示例2: __autoScrollAdvance
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import top [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")
示例3: popup
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import top [as 别名]
def popup(self, pos=None, searchText=""):
"""
Popup the menu at `pos` (in screen coordinates). 'Search' text field
is initialized with `searchText` if provided.
"""
if pos is None:
pos = QPoint()
self.__clearCurrentItems()
self.__search.setText(searchText)
patt = QRegExp("(^|\W)"+searchText)
patt.setCaseSensitivity(False)
self.__suggestPage.setFilterRegExp(patt)
self.ensurePolished()
if self.testAttribute(Qt.WA_Resized) and self.sizeGripEnabled():
size = self.size()
else:
size = self.sizeHint()
desktop = QApplication.desktop()
screen_geom = desktop.availableGeometry(pos)
# Adjust the size to fit inside the screen.
if size.height() > screen_geom.height():
size.setHeight(screen_geom.height())
if size.width() > screen_geom.width():
size.setWidth(screen_geom.width())
geom = QRect(pos, size)
if geom.top() < screen_geom.top():
geom.setTop(screen_geom.top())
if geom.left() < screen_geom.left():
geom.setLeft(screen_geom.left())
bottom_margin = screen_geom.bottom() - geom.bottom()
right_margin = screen_geom.right() - geom.right()
if bottom_margin < 0:
# Falls over the bottom of the screen, move it up.
geom.translate(0, bottom_margin)
# TODO: right to left locale
if right_margin < 0:
# Falls over the right screen edge, move the menu to the
# other side of pos.
geom.translate(-size.width(), 0)
self.setGeometry(geom)
self.show()
if searchText:
self.setFocusProxy(self.__search)
else:
self.setFocusProxy(None)
示例4: popup_position_from_source
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import top [as 别名]
def popup_position_from_source(popup, source, orientation=Qt.Vertical):
popup.ensurePolished()
source.ensurePolished()
if popup.testAttribute(Qt.WA_Resized):
size = popup.size()
else:
size = popup.sizeHint()
desktop = QApplication.desktop()
screen_geom = desktop.availableGeometry(source)
source_rect = QRect(source.mapToGlobal(QPoint(0, 0)), source.size())
if orientation == Qt.Vertical:
if source_rect.right() + size.width() < screen_geom.right():
x = source_rect.right()
else:
x = source_rect.left() - size.width()
# bottom overflow
dy = source_rect.top() + size.height() - screen_geom.bottom()
if dy < 0:
y = source_rect.top()
else:
y = source_rect.top() - dy
else:
# right overflow
dx = source_rect.left() + size.width() - screen_geom.right()
if dx < 0:
x = source_rect.left()
else:
x = source_rect.left() - dx
if source_rect.bottom() + size.height() < screen_geom.bottom():
y = source_rect.bottom()
else:
y = source_rect.top() - size.height()
return QPoint(x, y)
示例5: widget_popup_geometry
# 需要导入模块: from AnyQt.QtCore import QRect [as 别名]
# 或者: from AnyQt.QtCore.QRect import top [as 别名]
def widget_popup_geometry(pos, widget):
widget.ensurePolished()
if widget.testAttribute(Qt.WA_Resized):
size = widget.size()
else:
size = widget.sizeHint()
desktop = QApplication.desktop()
screen_geom = desktop.availableGeometry(pos)
# Adjust the size to fit inside the screen.
if size.height() > screen_geom.height():
size.setHeight(screen_geom.height())
if size.width() > screen_geom.width():
size.setWidth(screen_geom.width())
geom = QRect(pos, size)
if geom.top() < screen_geom.top():
geom.setTop(screen_geom.top())
if geom.left() < screen_geom.left():
geom.setLeft(screen_geom.left())
bottom_margin = screen_geom.bottom() - geom.bottom()
right_margin = screen_geom.right() - geom.right()
if bottom_margin < 0:
# Falls over the bottom of the screen, move it up.
geom.translate(0, bottom_margin)
# TODO: right to left locale
if right_margin < 0:
# Falls over the right screen edge, move the menu to the
# other side of pos.
geom.translate(-size.width(), 0)
return geom