[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 05:21:32 CEST 2014


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!;)

QTransformt=mMainView->viewportTransform();

QRectF  r  =  mMainView->viewport()->rect();

r  =  t.transposed().mapRect(r);

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.

Cheers,
Chris



More information about the Interest mailing list