How to enable anti-aliasing on Qlabel?

laurent picture laurent · Jul 19, 2011 · Viewed 11.2k times · Source

My QLabels look quite ugly, it seems that there's no anti-aliasing. How can I enable this feature (assuming it's available)?

Answer

Raiv picture Raiv · Jul 19, 2011
QLabel * l = new QLabel();
QFont f=l->font();
f.setStyleStrategy(QFont::PreferAntialias);
l->setFont(f);

you may also alter application font settings, to be applied to all widgets you use...

QFont f=QApplication::font();
f.setStyleStrategy(QFont::PreferAntialias);
QApplication::setFont(f);