1

I have seen that Qt integrates svg and also integrates javascript, but I have not found a way to execute the JavaScript embedded in a .svg

Does anyone know how to join these two functions in a Qt application?

SantiCDS
  • 41
  • 4

1 Answers1

2

You need to use QtWebKit to display your SVG file instead. Its SVG implementation can use the WebKit JavaScript engine. QtSvg cannot.

The simplest way is to create a QWebView widget. If you just want to verify that this works, compile the "fancybrowser" example included with the Qt source. I confirmed that "fancybrowser" can execute the inline JavaScript in an example SVG file from Matthew Bystedt's blog, using Qt 5.0.0 on Windows. I would guess that Qt 4.8.4 also supports it, but I haven't tried that myself.

typelist
  • 121
  • 3
  • Yes, the QWebView is a possible option, but my requeriments don´t allow use this class, I should have to use some QSvg class into a QGraphicView or other container, but nothing of QWebKit. Thanks so much – SantiCDS Jan 30 '13 at 07:58
  • Other ways of executing JavaScript using Qt are the QtScript module (based on an old version of WebKit's JavaScriptCore) and, in Qt 5, the QtV8 module (a recent version of Google's V8). Getting either to play nice with inline JavaScript in SVG files feels like it would require a non-trivial amount of effort, though. – typelist Jan 30 '13 at 15:39