Search code examples
pythonqtqgraphicsview

Qt display text in QGraphicsView undistorted, even in IgnoreAspectRatio views


Is there a way of somehow putting a QGraphicsTextItem so that the text is always displayed undistorted and in the same size with respect to the user?

Imagine a scene that is zoomed in and out, but has points that are marked with a dot and some text. If the texts is part of the scene it is zoomed with the scene and will be unreadable the most of the time.


Solution

  • You need to set QGraphicsItem::ItemIgnoresTransformations flag for text items. See the documentation:

    This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed.