Search code examples
c++qtantialiasing

Disable text anti-aliasing in Qt application


Since Qt does its own text rendering, is it possible to disable anti-aliasing for a Qt app at runtime, without changing the global OS settings?

If possible, I assume it would be done by tweaking the app's QStyle or something similar. Is that correct?


Solution

  • The QFont class exposes a setStyleStrategy() method that allows you to alter the font matching algorithm.

    Passing QFont::NoAntialias should achieve what you want:

    yourFont.setStyleStrategy(QFont::NoAntialias);