How would I go about adding an interactive SVG file to a QGraphicsScene? I can add an interactive SVG file, but it’s just displayed as a static image. I was reading about QGraphicsWebView but can’t figure out how add SVG files to it and examples are lacking.
Let me be a little more specific with what I’m looking for. Let’s say I have a SVG file that draws a box. When I mouse over that box I want to color to change triggered off a hover event. Do I have to edit the file and redraw the image? Feels like there should be a way of doing interactive SVG files with Qt.
I had the same problem and your question pointed me in right direction (using
QGraphicsWebView()).Solution is actually very simple:
It works perfect for me (scripting and other stuff).
As you can see, I’ve also loaded my svg as
QGraphicsSvgItem, because I didn’t know other way to get size of my svg.