laurent
laurent

Reputation: 90776

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)?

Upvotes: 11

Views: 13648

Answers (2)

Raiv
Raiv

Reputation: 5781

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);

Upvotes: 16

Yassine Zaroui
Yassine Zaroui

Reputation: 403

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

Upvotes: 2

Related Questions