SVG tooltips in QGraphicsView
-
I have looked through the QtSvg docs and can't find any pointers on what I want to achieve. I have an SVG that I currently display within a QGraphicsView and that works fine. What I want however is to mimic firefox's behaviour (I believe it also part of the SVG standard) that when moused over the elements title is displayed as a tooltip.
It is trivial to ascertain which QGraphicsSvgItem is under the mouse but I cant find any details about how you would find out more information such as the element within the SVG file. I have attached a sample SVG file and firefox gives the behaviour I want.
Thanks for reading.
!http://www.dur.ac.uk/a.j.poole/all.svg(Example SVG)! -
No SVG experience to speak of, but from the docs your most likely chance seems to be QSvgRenderer::boundsOnElement - provided you know the item IDs.
-
SVG support is not Qt's strong suit, I'm sorry to say. Hope you find a solution that works for you.
-
I agree that bounding boxes are not ideal as elements may have unsual geometries but in my case it is just about acceptable so I didn't go further in finding a better solution. I would love to hear about one if you find it however.
What I do is this:
- Parse svg to find element ID and title.
- calculate each elements bounds with QSvgRenderer::boundsOnElement
- on mouse events check if element bounds contains the mouse position
-
I agree that bounding boxes are not ideal as elements may have unsual geometries but in my case it is just about acceptable so I didn't go further in finding a better solution. I would love to hear about one if you find it however.
What I do is this:
- Parse svg to find element ID and title.
- calculate each elements bounds with QSvgRenderer::boundsOnElement
- on mouse events check if element bounds contains the mouse position