Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable anti-aliasing on Qlabel?

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

like image 753
laurent Avatar asked Jul 19 '11 11:07

laurent


Video Answer


2 Answers

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);
like image 135
Raiv Avatar answered Oct 07 '22 00:10

Raiv


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

like image 38
Yassine Zaroui Avatar answered Oct 06 '22 22:10

Yassine Zaroui