本文整理匯總了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()