# High DPI Support QPainter::drawText

• Hi Guys,

I have a problem with HighDPI-Support and drawing text into an image with a painter.
HighDPI-Support is activated (before the QApplication is started) via

``````QApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
QApplication::setAttribute( Qt::AA_UseHighDpiPixmaps );
``````

The image and the text is drawn as follows:

``````QPixmap image = source->scaledToWidth( newWidth, Qt::SmoothTransformation );
...

QPainter painter( &image );
painter.setRenderHint( QPainter::TextAntialiasing );
painter.setRenderHint( QPainter::Antialiasing );
painter.drawText( rect, Qt::AlignCenter, str );

ui.label_image->setPixmap( image );
``````

The result is an aliased text in the image (this is on a 4K monitor).

If I disable high DPI support, the text in the image is better, especially antialiazed (this is on a FullHD Monitor).

As I write this post, I noticed that not only the text, but also the image itself (HighDPI version) is aliased.
Does anybody know why?

regards
Oliver

• Hi,

Sorry I don't have a direct answer for that. In any case what version of Qt are you using ? There's been quite some work on the HighDPI side in the latest releases which may behave better.

• I'm using Qt 5.12.5.

• You should try with Qt 5.14.1 to see if it as improved.

• Qt 5.14.1 has the same problem.

• Did you check the bug report system ?