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) viaQApplication::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.
-
You should try with Qt 5.14.1 to see if it as improved.
-
Did you check the bug report system ?