[Qt-interest] How to scroll text drawn with Qpainter in QGraphicsview

Sean Harmer sean.harmer at maps-technology.com
Mon Aug 24 16:14:48 CEST 2009


On Monday 24 Aug 2009 14:26:59 _h_ wrote:
> Hi John,
>
> > If the scene is larger than the view's viewport, the view displays
>
> scrollbars.
> As I am drawing text using QPainter it is not resizing the QGraphicsView,
>  but if I use the QGraphicsTextItem the view gets resize accordingly.
>
> > You re> placed the viewport with a QGLWidget. QGLWidgets don't resize
> > when
>
> drawing goes past the borders so the view doesn't display scrollbars.
>
> No I am not using QGLWidget as viewport.
>
> > You can try manually resizing the viewport to accomodate the text.
>
> Any suggestion.
Yes.

(i) use a QGraphicsTextItem.
(ii) use a custom class derived from QGraphicsItem.
(iii) if you must use a QGraphicsView subclass directly then make sure you set 
a large enough sceneRect() on it.

Cheers,

Sean



More information about the Qt-interest-old mailing list