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)))
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)
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
def visualRegionForSelection(self, selection): return QRegion()