Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Antialiasing not working in QGraphicsView

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 ?

like image 825
Algo Avatar asked Jul 18 '13 21:07

Algo


1 Answers

Please see my comments for this question.

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

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

like image 100
Patrick Avatar answered Nov 20 '22 10:11

Patrick