[Interest] QGraphicsScene: How to get the scene rect displayed on the screen (not the qgv.sceneRect())

Christian Gagneraud chgans at gna.org
Mon May 26 07:54:31 CEST 2014


On 26/05/2014 3:21 p.m., Christian Gagneraud wrote:
> Hi there,
 >
 > I am trying to implement an "oversight" view, that is a small view
 > that always display the full scene (plus a little margin) and draw a
 > red rectangle that correspond to the scene rect that is displayed on
 > the screen by the "main" view, my feeling is that I have to use the
 > viewport of the qgraphicsview, but I can't find out how to achieve
 > this. I tried naively to use mainview->sceneRect() but it return the
 > scene rect that is accessible within the view (including parts that
 > will be displayed when moving the scroll bars).
 >
 > As usual, as I'm writing this email and at the same time keep reading
 > the doc and testing stuff, I think I found it!;)
 >
 > QTransform t = mMainView->viewportTransform();
 > QRectF  r  =  mMainView->viewport()->rect();
 > r  =  t.transposed().mapRect(r);

Correcting myself, it's not t.transposed() but t.inverted()

>
 > It seems to do the job, not sure it's pixel perfect, but it seems
 > good enough for me. If anyone has comment or advice on doing this
 > kind of things, I'm still interesting!
 >
 > My next step will be to forbid scene interaction within the
 > "oversight" view, but still allowed the user to resize the main view
 > area (the red rectangle) within the oversight view.

Still working on that one, I found some forum post talking about 
connecting to the scrollbars of the view, ....
I'm a bit doubtful about that one.

Chris

>
 > Cheers, Chris



More information about the Interest mailing list