Important: Please read the Qt Code of Conduct -

QLabel and image antialiasing

  • Hello , excuse me if this forum is not pertinent to my question but i do not know where to post, i am using a qlabel to draw an image and actually i do not want it to be antialised when zoomed in, how can i achieve this ?

  • Lifetime Qt Champion

    Hi and welcome to the forums
    It is a perfectly fine place to ask :)

    QLabel uses Qt::SmoothTransformation and there seems not to be a way to disable it

    But you can easily make a custom widget with paintEvent and draw the image
    yourself not using smoothing.

  • @mrjj Holy cow, how can i draw a raw bitmap pixel by pixel ????

  • @v8671 said in QLabel and image antialiasing:

    Holy cow, how can i draw a raw bitmap pixel by pixel ????

    That's not what was suggested.

    @mrjj was talking of something like:

    class NonAntiAliasImage : public QWidget{
        explicit NonAntiAliasImage(QWidget* parent = Q_NULLPTR) 
            : QWidget(parent)
        const QPixmap& pixmap() const 
            return m_pixmap;
        void setPixmap(const QPixmap& px) 
            m_pixmap = px;
        void paintEvent(QPaintEvent*)
            QPainter painter(this);
            painter.setRenderHint(QPainter::Antialiasing, false);
            style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter, m_pixmap.scaled(rect().size()));
        QPixmap m_pixmap;

  • Thanks Vronin , that worked flawlessly

Log in to reply