本文整理汇总了Python中qtpy.QtCore.QRect方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QRect方法的具体用法?Python QtCore.QRect怎么用?Python QtCore.QRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore
的用法示例。
在下文中一共展示了QtCore.QRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QRect [as 别名]
def paintEvent(self, event):
edit = self.edit
height = edit.fontMetrics().height()
block = edit.firstVisibleBlock()
count = block.blockNumber()
painter = QPainter(self)
painter.fillRect(event.rect(), edit.palette().base())
first = True
while block.isValid():
count += 1
block_top = edit.blockBoundingGeometry(block).translated(
edit.contentOffset()).top()
if not block.isVisible() or block_top > event.rect().bottom():
break
rect = QRect(0, block_top, self.width(), height)
self.draw_block(painter, rect, block, first)
first = False
block = block.next()
painter.end()
super(PromptArea, self).paintEvent(event)
示例2: pixmap
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QRect [as 别名]
def pixmap(self, size, mode, state):
pm = QPixmap(size)
pm.fill(Qt.transparent)
self.paint(QPainter(pm), QRect(QPoint(0, 0), size), mode, state)
return pm
示例3: frameNodes
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QRect [as 别名]
def frameNodes(self, nodes):
if len(nodes) == 0:
return
def computeWindowFrame():
windowRect = self.rect()
windowRect.setLeft(windowRect.left() + 16)
windowRect.setRight(windowRect.right() - 16)
windowRect.setTop(windowRect.top() + 16)
windowRect.setBottom(windowRect.bottom() - 16)
return windowRect
nodesRect = None
for node in nodes:
nodeRectF = node.transform().mapRect(node.rect())
nodeRect = QtCore.QRect(nodeRectF.x(), nodeRectF.y(), nodeRectF.width(), nodeRectF.height())
if nodesRect is None:
nodesRect = nodeRect
else:
nodesRect = nodesRect.united(nodeRect)
windowRect = computeWindowFrame()
scaleX = float(windowRect.width()) / float(nodesRect.width())
scaleY = float(windowRect.height()) / float(nodesRect.height())
if scaleY > scaleX:
scale = scaleX
else:
scale = scaleY
if scale < 1.0:
self.setTransform(QtGui.QTransform.fromScale(scale, scale))
else:
self.setTransform(QtGui.QTransform())
sceneRect = self.sceneRect()
pan = sceneRect.center() - nodesRect.center()
sceneRect.translate(-pan.x(), -pan.y())
self.setSceneRect(sceneRect)
# Update the main panel when reframing.
self.update()