PDA

View Full Version : Zoom buttons using QGraphics objects



PrimeCP
15th February 2008, 00:17
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).

Thanks

spud
15th February 2008, 11:38
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 (http://www.qtcentre.org/forum/f-qt-programming-2/t-drawforeground-update-trouble-11470.html).