def paintEvent(self, event):
background = QRadialGradient(QPointF(self.rect().topLeft()), 500,
QPointF(self.rect().bottomRight()))
background.setColorAt(0, self.backgroundColor1)
background.setColorAt(1, self.backgroundColor2)
painter = QPainter()
painter.begin(self)
painter.setRenderHint(QPainter.Antialiasing)
painter.fillRect(event.rect(), QBrush(background))
painter.setPen(self.pen)
for bubble in self.bubbles:
if QRectF(bubble.position - QPointF(bubble.radius, bubble.radius),
QSizeF(2*bubble.radius, 2*bubble.radius)).intersects(QRectF(event.rect())):
bubble.drawBubble(painter)
if self.newBubble:
self.newBubble.drawBubble(painter)
painter.end()
评论列表
文章目录