Ejemplo n.º 1
0
 def shape(self):
    """ Returns the shape of this item as a QPainterPath in local
        coordinates. The shape is used for many things, including
        collision detection, hit tests, and for the QGraphicsScene::items()
        functions.
    """
    path = QtGui.QPainterPath()
    rect = self.boundingRect()
    path.addRect(rect)
    return path
Ejemplo n.º 2
0
 def paintEvent(self, event):
     m = 9
     path = QPainterPath()
     path.setFillRule(Qt.WindingFill)
     path.addRect(m, m, self.width() - m * 2, self.height() - m * 2)
     painter = QPainter(self)
     painter.fillPath(path, QBrush(Qt.white))
     color = QColor(100, 100, 100, 30)
     for i in range(m):
         path = QPainterPath()
         path.setFillRule(Qt.WindingFill)
         path.addRoundRect(m - i, m - i,
                           self.width() - (m - i) * 2,
                           self.height() - (m - i) * 2, 1, 1)
         color.setAlpha(90 - math.sqrt(i) * 30)
         painter.setPen(QPen(color, 1, Qt.SolidLine))
         painter.drawRoundRect(
             QRect(m - i, m - i,
                   self.width() - (m - i) * 2,
                   self.height() - (m - i) * 2), 0, 0)