PDA

View Full Version : Graphics view rubberband zooming



Veeru
3rd April 2008, 09:48
Hi guys,

I had a graphics view in my application , it has items on it , i implimented zoom according to 40000 chips example.It is working fine , but i would like to zoom the selected area.That area is selected by ruberband , it selects items covered by that area.

For rubber band i am using this function
view->setDragMode (QGraphicsView::RubberBandDrag );
The actual problem is , for this what event is going to call, i am not under standing.
I have tried all the events , how to catch the drag event.


please help me
Thank you ,

Regards
Veeru

aamer4yu
3rd April 2008, 09:59
Setting the drag mode as Rubberband drag, you will only be able to select items based on the selection.
To implement the zoom based on rubberband, u will need to implement ur own rubberband.
For this u need to catch the mouse events in scene or view. Based on this, once u get the rectangle after rubberbanding, u just nee to call fitInView() function.

I will check if I have a pseudo code. I had implemented the rubberband zooming in one of my application long back.

aamer4yu
5th April 2008, 09:17
Here's a part of my code for rubber banding.
I implemented in GraphicsView class, u can implement in QGraphicsScene class too.

Hope it helps you :)

zgulser
24th February 2010, 13:06
Hi,

if(isPointInSceneRect(m_selectiveZoomStart) && isPointInSceneRect(m_selectiveZoomEnd))
{
// fiv the rect
// fit in view the rect - zoomRect.toRect()
}

what's "fiv the rect" here?

I did almost what you said here but there is a mismatching between my cursor position and rubberband drawing position..

zgulser
25th February 2010, 09:52
So does anyone has an idea?

aamer4yu
25th February 2010, 11:14
what's "fiv the rect" here?
fiv means fit in view !

You seem to be taking event->pos()... there must be some prob in mapping cordinates..
check in the example I had posted b4..I had used global points for mouse press , etc.

Also the selective zoom on means where zoom based on rubberbanding is on. Look again at the cordinates, and am sure you will be able to solve it.