Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set correct PointSize in a QGraphicsTextItem
Jupiter last edited by
I want to have a QGraphicsTextItem with the correct point size (1pt = 0.3527mm). however 1 unit in my scene is 1 mm.
i tried to call setPointSizeF() with the correct calculated size, but somehow only the pointsize() is called for drawing the text. So only about every third pt the actual font size is changed (3*0.3527 ~ 1.0). How can i change this?
sraboisson last edited by
Perhaps your falling in the documentation remark of "setPointSizeF":
"... The requested precision may not be achieved on all platforms"
Did you try using "setPixelSize" (calculating the pixel size corresponding to the desired font height) ?
float lPixelSizeInMillimeters = 0.3527;
float lFontSizeInMillimeters = 12.4:
lFontSizeInPixels = (int)(lFontSizeInMillimeters / lPixelSizeInMillimeters) m_textFont.setPixelSize(lFontSizeInPixels);
Hope this is possible and will help...