Question

I have three QPaintDevices, a Qlabel , a QImage and a QPrinter. When i try to draw non textual elements like rectangle , i got same output on all three devices. But when i try to draw text through QPainter.drawText the result on QLabel and QImage is same and QPriner output differs.(QPrinter output is a PDF file). actually the text size in Qlabel and QImage is bigger than text size in output PDF file.Waht is the cause of difference?

Was it helpful?

Solution

The difference is coming most probably because of the resolution settings. See enum QPrinter::PrinterMode

Also, QPrintSupport Class documentation states

Note: When rendering text on a QPrinter device, it is important to realize that the size of text, when specified in points, is independent of the resolution specified for the device itself. Therefore, it may be useful to specify the font size in pixels when combining text with graphics to ensure that their relative sizes are what you expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top