You have to explicitly set the sceneRect
of the QGraphicsScene
. Otherwise, it will grow automatically. You will want it to be fixed size.
Then, you need to subclass QGraphicsTextItem
, or create your own QGraphicsItem from scratch.
Maybe if you override virtual QRectF boundingRect () const
, you could call the base boundingRect
, do a check if it's outside the scene rect, and move the item to the left with setPos
.
Remember that the bounding rect is in item coordinates, you need to consider the item position to get the scene coordinates.