Results 1 to 2 of 2

Thread: Zoom buttons using QGraphics objects

  1. #1
    Join Date
    Jan 2006
    Qt products
    Qt3 Qt4 Qt/Embedded
    Unix/X11 Windows

    Default Zoom buttons using QGraphics objects

    I have a GraphicsView/Scene with arrows and boxes, zooming, panning and moving the boxes all work but via the mouse buttons (wheel button zooms).

    I would like to add buttons similar to what you see on map programs where the zoom in and zoom out are placed directly on the map.

    My initial thought was to draw them using the drawForeground method in QGraphicsView but I found that my scaling and panning also moves them and determining mouse presses on that is less than ideal.

    What would be the best way to do this? Is there a way to anchor them in the corner so there size and placement never change (any ideas on best way to capture a mouse press on them)? Can I anchor a QGraphicsItem in such a way, or maybe I should draw on the viewport (again the mouse press capture would not be ideal).


  2. #2
    Join Date
    Oct 2006
    Thanked 40 Times in 39 Posts
    Qt products
    MacOS X Unix/X11 Windows

    Default Re: Zoom buttons using QGraphics objects

    I have come across this problem beforeand there is no obvious solution to implement overlays with GraphicsView. One would think drawForeground() is the place to do it, but as it works in scene coordinates it is not so convienient. The general problem is to tell the viewport which areas to update while panning. See this thread.


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.