How to enable anti-aliasing on Qlabel?
Asked Answered
N

2

11

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

Nissensohn answered 19/7, 2011 at 11:16 Comment(3)
This 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.Algar
You probably should tell what OS you are using. My QLabels look just fine.Sharl
Are you using Qt software rendering (raster) ?Phanerozoic
C
16
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);
Creath answered 19/7, 2011 at 11:34 Comment(1)
Remember that iz is QFont::PreferAntialias.Morissa
D
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

Dehydrogenate answered 19/7, 2011 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.