Quote Originally Posted by wysota View Post
It's not what I told you to do. You need to redefine boundingRect() for the text item by subclassing it or wrapping it into another item with origin in the centre of the item.
I am not trying to argue, just understand. Wrapping or subclassing the text item doesn't help, because it still has an internal coordinate system in pixels.

So, I am almost at a solution. I turned off ItemIgnoresTransformations for the QGraphicsSimpleTextItem instance. So, now when I obtain the text width and call textItem->mapRectToParent( textItem->boundingRect() ), I get a rect in centimeters. I can center the text because I have apples + apples.

To prevent it from scaling, I set a scale transform on the text item that is the inverse of the centimeter item's scale (i.e. 1 / sx, 1 / sy). So now the text remains the same size regardless of the scale of the centimeter item.

A few more tweaks, and I think I will have something that behaves the way I want it to.

Thank you for the help.