Antialiasing not working in QGraphicsView

Algo picture Algo · Jul 18, 2013 · Viewed 7.5k times · Source

I re-implemented QGraphicsView to have the scene zoomed with a mouse wheel event. The scene contains several QGraphicsPixmapItem. The wheel event calls QGraphicsView::scale(qreal sx, qreal sy)

Everything works perfectly but the rendering. As I zoom out (the scene gets smaller), aliasing appears. I tried setting the render hints as following in the re-implemented QGraphicsView constructor:

ImageViewer::ImageViewer(QWidget * parent) :
  QGraphicsView(parent)
{
   setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
}

I still see these artifacts. How can I get rid of this ?

Answer

Patrick picture Patrick · Aug 18, 2013

Please see my comments for this question.

Basically you have to call setTransformationMode(Qt::SmoothTransformation) on the QGraphicsItems you want anti-aliasing to apply to.

Calling setRenderHints on the view did not work for me, either.