(self, painter: QPainter, option, widget=None)
| 121 | return path |
| 122 | |
| 123 | def paint(self, painter: QPainter, option, widget=None) -> None: |
| 124 | r = self.boundingRect() |
| 125 | if self._renderer is not None: |
| 126 | self._renderer.render(painter, r) |
| 127 | elif self._pixmap is not None: |
| 128 | px = self._pixmap |
| 129 | # Centre in bounding rect (pixmap may be smaller due to aspect ratio) |
| 130 | x_off = (r.width() - px.width()) / 2 |
| 131 | y_off = (r.height() - px.height()) / 2 |
| 132 | painter.setRenderHint(QPainter.SmoothPixmapTransform) |
| 133 | painter.drawPixmap(int(x_off), int(y_off), px) |
| 134 | else: |
| 135 | painter.fillRect(r, _PLACEHOLDER_COLOR) |
| 136 | if option.state & _SELECTED: |
| 137 | painter.save() |
| 138 | painter.setPen(_SEL_PEN) |
| 139 | painter.setBrush(Qt.NoBrush) |
| 140 | painter.drawRect(r) |
| 141 | painter.restore() |
| 142 | |
| 143 | def itemChange(self, change, value): |
| 144 | if change == QGraphicsItem.ItemPositionChange: |
nothing calls this directly
no test coverage detected