Disabling antialiasing when drawing fonts in Qt 4.8.x

When you draw text in Qt using QPainter and desire it to be pixel crisp and sharp, you might do something like this:

QPainter painter(&this);
painter.setRenderHint(QPainter::TextAntialiasing, false);
painter.drawText(this.rect(), "Some Text");
Qt 4.8.x QPainter drawing text with default anti-aliasing on
Qt 4.8.x QPainter drawing text with default anti-aliasing on

However, sometimes it doesn’t work. Your text might be drawn with antialiasing no matter what, which results in soft blurry sometimes ugly font. Continue reading “Disabling antialiasing when drawing fonts in Qt 4.8.x”