'Smooth Pixmap Transformation in QGraphicsView Does Not Work

note: Antialiasing not working in QGraphicsView does not work for me.

I am trying to enable anti-aliasing and/or smooth pixmap transformations to a QGraphicsView. The following is the entire program. It successfully displays the image at 20% scale, but without any smoothing.

Everywhere I've looked, it seems like setting the transformation mode of the QGraphicsPixmapItem and the render hints of the QGraphicsView should be enough, but neither works in my case.

GraphicsView.pro

QT += core gui widgets
SOURCES += main.cpp

main.cpp

#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QMainWindow>
#include <QPixmap>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QMainWindow window;
    QGraphicsScene scene;
    QGraphicsView view;
    QGraphicsPixmapItem item;
    QPixmap pixmap;

    pixmap.load("../textures/image.jpg");
    item.setTransformationMode(Qt::SmoothTransformation);
    item.setPixmap(pixmap);
    scene.addItem(&item);
    view.setScene(&scene);
    view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
    view.scale(0.2, 0.2);
    window.setCentralWidget(&view);
    window.show();

    return a.exec();
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source