本文整理汇总了Python中PySide.QtGui.QPainter.fillPath方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.fillPath方法的具体用法?Python QPainter.fillPath怎么用?Python QPainter.fillPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainter
的用法示例。
在下文中一共展示了QPainter.fillPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import fillPath [as 别名]
def paintEvent(self, event):
"""Display a translucent rounded rectangle."""
roundness = 10
rect = self.rect()
bgcolor = self.palette().color(QPalette.Background)
alpha_bgcolor = QColor(50, 50, 50, 150)
# alpha_bgcolor = QColor(bgcolor.red(), bgcolor.green(),
# bgcolor.blue(), 150)
painter = QPainter()
painter.begin(self)
painter.save()
painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(Qt.red)
rounded_rect = QPainterPath()
rounded_rect.addRoundRect(1, 1, rect.width() - 2, rect.height() - 2, roundness, roundness)
painter.setClipPath(rounded_rect)
self.setMask(painter.clipRegion())
painter.setOpacity(1.0)
painter.fillPath(rounded_rect, QBrush(alpha_bgcolor))
painter.restore()
painter.end()
示例2: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import fillPath [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
# Фон
painter_path = QPainterPath()
painter_path.addRect(0, 0, self.width() - 1, self.height() - 1)
painter.fillPath(painter_path,
QBrush(QImage(':/main/background.png')))
if self.image:
painter.drawText(10, 20, str(self.image.draw_scale))
painter.setTransform(QTransform().
scale(self.image.draw_scale, self.image.draw_scale).
translate(self.image.draw_offset.x(), self.image.draw_offset.y()))
old_pen = painter.pen()
new_pen = QPen()
new_pen.setColor(QColor(0, 150, 0))
painter.setPen(new_pen)
self.image.draw(painter)
painter.setPen(old_pen)