Results 1 to 6 of 6

Thread: Graphics view rubberband zooming

  1. #1
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Post Graphics view rubberband zooming

    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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics view rubberband zooming

    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.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics view rubberband zooming

    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
    Attached Files Attached Files

  4. The following user says thank you to aamer4yu for this useful post:

    lycium (23rd March 2010)

  5. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Graphics view rubberband zooming

    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..
    Attached Files Attached Files
    Last edited by zgulser; 24th February 2010 at 14:29.

  6. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Graphics view rubberband zooming

    So does anyone has an idea?

  7. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics view rubberband zooming

    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.

Similar Threads

  1. Qt Coordinate System and the Graphics View Framework
    By djurodrljaca in forum Qt Programming
    Replies: 14
    Last Post: 17th February 2012, 11:19
  2. Graphics View Event Propagation
    By pherthyl in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2008, 10:39
  3. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  4. which is better QCanvas or graphics view?
    By neomax in forum General Discussion
    Replies: 1
    Last Post: 23rd November 2006, 15:19
  5. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.