[PyQt] [pyqt] drawPixmap() in a QGraphicsItem.paint() / SmoothTransformation issue

Philippe Crave philippe.crave at gmail.com
Wed Apr 7 19:33:13 BST 2010


Had to set it in the View !

self.view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)


2010/4/2 Philippe Crave <philippe.crave at gmail.com>:
> Hi,
>
> In a QGraphicsItem, I use painter.drawPixmap() in the paint() method.
> but when I resize the QGraphicsView, the Pixmap is not that pretty.
>
> If I put that pixmap in a QGraphicsPixmapItem, then, I can set the
> setTransformationMode(Qt.SmoothTransformation). the result is perfect
> in any situation.
>
> but is it possible to get a Qt.SmoothTransformation of a QPixmap in
> the following code sample ?
>
> /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /
>  /  /  /  /  /
> class Page(QGraphicsItem):
>
>     Rect = QRectF(0, 0, 800, 480)
>
>     def __init__(self, parent):
>         super(Page, self).__init__(parent)
>         self.setPos(self.mapFromParent(QPointF(0, 0)))
>         self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsMovable)
>        self.bg_pix = QPixmap('pic.png')
>
>     def boundingRect(self):
>         return Page.Rect
>
>     def paint(self, painter, option, widget=None):
>         painter.drawPixmap(QPointF(0, 0), self.bg_pix)
> /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /  /
>  /  /  /  /  /
>
> thank you,
> Philippe
>


More information about the PyQt mailing list