When using QWidget::render() to render a widget to a QPrinter, a rasterized version of the widget is painted. This can clearly be seen if the printer output is saved to a PDF and opened in a PDF reader. The output looks really ugly when zoomed in.
A workaround is to render the widget to a QSvgGenerator and then converting that output to a PDF, but it seems rather cumbersome.
There seems to be a check in QWidget::render() which tells Qt to rasterize the output when rendering to a printer. Some helpful develpers found this commit description:
"We have to render via a pixmap, since the printer device is not persistent in beteween QPainter::begin()/end() calls."
It would be nice if a workaround was implemented so that rendering to a printer would not result in raster images which look ugly when zoomed in.
Attached is a small program which produces an ugly-looking PDF.