Esempio n. 1
0
    def testFunctionUnit(self):
        r = QRegion(0, 0, 10, 10)
        r2 = QRegion(5, 5, 10, 10)
 
        ru = r.united(r2)
        self.assert_(ru.contains(QPoint(0,0)))
        self.assert_(ru.contains(QPoint(5,5)))
        self.assert_(ru.contains(QPoint(10,10)))
        self.assert_(ru.contains(QPoint(14,14)))
Esempio n. 2
0
def roundCorners(rectangle, radius):
        '''Get region for setting round edges mask'''
        region = QRegion()
        region += rectangle.adjusted(radius,0,-radius,0)
        region += rectangle.adjusted(0,radius,-0,-radius)
        
        corner = QRect(rectangle.topLeft(), QSize(radius*2,radius*2))
        region += QRegion(corner, QRegion.Ellipse)
        
        corner.moveTopRight(rectangle.topRight())
        region += QRegion(corner, QRegion.Ellipse)
        
        corner.moveBottomLeft(rectangle.bottomLeft())
        region += QRegion(corner, QRegion.Ellipse)
        
        corner.moveBottomRight(rectangle.bottomRight())
        region += QRegion(corner, QRegion.Ellipse)
        
        return region
    def paint(self, painter, option, index):
        assert isinstance(painter, QPainter)
        assert isinstance(index, QModelIndex)

        device = painter.device()

        widget = CelebItemWidget()
        widget.set_celeb(index.data(Qt.EditRole))
        # widget.setGeometry(option.rect)
        widget.render(painter, QPoint(option.rect.x(), option.rect.y()),
                      QRegion(), QWidget.DrawChildren)
Esempio n. 4
0
def mask(rect, r):
    region = QRegion()
    region += rect.adjusted(r, 0, -r, 0)
    region += rect.adjusted(0, r, 0, -r)

    # top left
    corner = QRect(rect.topLeft(), QSize(r * 2, r * 2))
    region += QRegion(corner, QRegion.Ellipse)

    # top right
    corner.moveTopRight(rect.topRight())
    region += QRegion(corner, QRegion.Ellipse)

    # bottom left
    corner.moveBottomLeft(rect.bottomLeft())
    region += QRegion(corner, QRegion.Ellipse)

    # bottom right
    corner.moveBottomRight(rect.bottomRight())
    region += QRegion(corner, QRegion.Ellipse)

    return region
Esempio n. 5
0
 def visualRegionForSelection(self, selection):
     return QRegion()