本文整理汇总了Python中PyQt4.QtCore.QSize.scale方法的典型用法代码示例。如果您正苦于以下问题:Python QSize.scale方法的具体用法?Python QSize.scale怎么用?Python QSize.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QSize
的用法示例。
在下文中一共展示了QSize.scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import scale [as 别名]
def paintEvent(self, event):
crect = self.rect()
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.setBrush(QBrush(Qt.white))
painter.setPen(QPen(Qt.lightGray, 1.2))
painter.drawRoundedRect(QRectF(crect).adjusted(2, 2, -2, -2), 2, 2,
Qt.AbsoluteSize)
if self._selected:
painter.setPen(QPen(QBrush(Qt.red), 2))
if self._highlighted:
painter.setBrush(QBrush(Qt.gray, Qt.FDiagPattern))
else:
painter.setBrush(Qt.NoBrush)
painter.drawRoundedRect(QRectF(crect).adjusted(2, 2, -2, -2), 2, 2,
Qt.AbsoluteSize)
defsize = self.renderer().defaultSize()
margin = 5
bound = QSize(defsize)
bound.scale(crect.width() - margin, crect.height() - margin,
Qt.KeepAspectRatio)
svgrect = QRectF(0, 0, bound.width(), bound.height())
svgrect.moveCenter(crect.center())
self.renderer().render(painter, svgrect)
示例2: paintEvent
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import scale [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
size = QSize(1, 1)
size.scale(self.width() - 1, self.height() - 1, Qt.KeepAspectRatio)
matrix = QMatrix()
matrix.translate((self.width() - size.width()) / 2, (self.height() - size.height()) / 2)
painter.setMatrix(matrix)
self.__startAngle = 0
for polozka in self.__polozky:
self.kresliPolozku(painter, size, polozka[0], polozka[1], polozka[2])
self.__startAngle = 0
for polozka in self.__polozky:
self.kresliText(painter, size, polozka[0], polozka[1], polozka[2])