How to get the correct size from QStaticText
Asperamanca last edited by
I have a QStaticText that gets drawn using painter->drawStaticText.
I call prepare() on the StaticText whenever I change text, font or alignment.
Before I draw, however, I need to use the size() method of QStaticText, in order to calculate the correct position.
Since I called prepare(), it should contain the correct size already.
Usually it does. But on some computers, the text "jumps", because the size of the staticText changes, although none of the input parameters I control has changed.
Unfortunately, it is only updated in drawStaticText - too late to be taken into account by me.
Is there any method of QStaticText I could call to check whether the text needs to be updated, so that I can get a correct size before drawing?
I now also compare the transformation I used on prepare() versus the painter's world transformation, and manually call prepare when they are not equal.