Important: Please read the Qt Code of Conduct -

QPainter FontMetrics returns different values on the same Graphics view and scene

  • I have two graphics rect items drawn on the same graphics scene and graphics view. I am rendering text on the rect items for which I take font metrics from the painter to calculate text width and height.

    As per observation for other graphics items, the value of painter->fontMetrics->height() and painter->fontMetrics->averageCharWidth() increases in value when moving a screen of low dpi to high dpi.

    What could be the issue that painter->fontMetrics() is different for the two graphics items which are drawn in the same manner?

    Picture for reference:

    Please help.

Log in to reply