My QLabels look quite ugly, it seems that there's no anti-aliasing. How can I enable this feature (assuming it's available)?
Asked
Active
Viewed 1.3k times
10
-
1This is a very wild guess since I don't have experience with Qt, but does setting a background color solve the problem ? Many UI systems don't do font anti-aliasing without a background since the aliased pixels depend on a background color to blend in to. – DarkDust Jul 19 '11 at 11:20
-
You probably should tell what OS you are using. My QLabels look just fine. – Jul 19 '11 at 11:29
-
Are you using Qt software rendering (raster) ? – Thomas Vincent Jul 19 '11 at 13:49
2 Answers
15
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);
2
You can set the Antialisasing attribute in the label's font to PreferAntialias. You can do it in QtCreator or by code like this :
QFont f("Times", 50);
f.setStyleStrategy(QFont::PreferAntialias);
ui->label->setFont(f);
Hope this helps

Yassine Zaroui
- 403
- 3
- 14