在qt应用程序中集成Svg和Javascript [英] Integration of Svg and Javascript in qt application

查看:411
本文介绍了在qt应用程序中集成Svg和Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到Qt集成svg并且还集成了javascript,但我还没有找到一种方法来执行嵌入在.svg中的JavaScript

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

有没有人知道要在Qt应用程序中加入这两个函数?

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

推荐答案

您需要使用QtWebKit来显示您的SVG文件。它的SVG实现可以使用WebKit JavaScript引擎。 QtSvg不能。

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

最简单的方法是创建一个 QWebView 小部件。如果你只是想验证这是否工作,编译Qt源包含的fancybrowser示例。我确认fancybrowser可以在 Matthew Bystedt博客的示例SVG文件中执行内联JavaScript ,在Windows上使用Qt 5.0.0。我猜想Qt 4.8.4也支持它,但我没有自己尝试过。

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.

这篇关于在qt应用程序中集成Svg和Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆