user2123079
user2123079

Reputation: 686

QGraphicsSimpleTextItem antialiasing doesn't work

I set text to my QGraphicsSimpleTextItem which is in QGraphicsItem and seems that text antialiasing is not working or work very bad. I tried to set

font.setStyleStrategy(QFont::StyleStrategy::PreferAntialias);

and have override

void MyClass::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    painter->setRenderHints(painter->renderHints() | QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);
    QGraphicsItem::paint(painter, option, widget);
}

but text is still the same.

enter image description here

Upvotes: 0

Views: 233

Answers (1)

user2123079
user2123079

Reputation: 686

My paint() function was done with help of OpenGL. I just created surface format without supporting multisampling for antialiasing. I had to write:

QSurfaceFormat sf = QSurfaceFormat::defaultFormat();
sf.setSamples(4);

Upvotes: 1

Related Questions