[Kde-bindings] include in QScript via Kross
Andreas Marschke
xxtjaxx at googlemail.com
Mon Mar 8 14:19:05 UTC 2010
Am Montag 08 März 2010 13:33:10 schrieb Richard Dale:
> On Monday 08 March 2010 11:57:14 am Andreas Marschke wrote:
> > Hi!
> >
> > Some days ago sebsauer did me a favor and added an include function to
> > QScript in Kross which enables users to open up additional functionality
> > in Krosses QScript. The problem now is when I run something like
> > include("svg");
> > or
> > include("qtscript_svg");
> > I get :
> > Error: Unable to import qtscript_svg: no such extension.
> >
> > I've checked if the svg plugin is in the QT_PLUGIN/scripts/ directory and
> > yes it is. Was it just a typo from me or did I do something substentially
> > wrong when trying to include these plugins?
>
> How have you defined your plugin class? In the JSmoke bindings the qt svg
> module is defined like this:
>
> class jsmoke_qtsvg_ScriptPlugin : public QScriptExtensionPlugin
> {
> public:
> QStringList keys() const;
> void initialize(const QString &key, QScriptEngine *engine);
> };
>
> QStringList jsmoke_qtsvg_ScriptPlugin::keys() const
> {
> QStringList list;
> list << QLatin1String("jsmoke");
> list << QLatin1String("jsmoke.qtsvg");
> return list;
> }
>
> void jsmoke_qtsvg_ScriptPlugin::initialize(const QString &key,
> QScriptEngine *engine)
> {
> if (key == QLatin1String("jsmoke")) {
> } else if (key == QLatin1String("jsmoke.qtsvg")) {
> QScriptValue extensionObject = engine->globalObject();
> qtscript_initialize_jsmoke_qtsvg_bindings(extensionObject);
> } else {
> Q_ASSERT_X(false, "jsmoke_qtsvg::initialize", qPrintable(key));
> }
> }
>
> Q_EXPORT_STATIC_PLUGIN(jsmoke_qtsvg_ScriptPlugin)
> Q_EXPORT_PLUGIN2(jsmoke_qtsvg, jsmoke_qtsvg_ScriptPlugin)
>
> Then I can import using the name "jsmoke.qtsvg" in javascript programs.
>
> -- Richard
I didnt write them myself actually they are provided by my distro(Debian).
See the source package for qtscriptgenerator as a source of what they did.
afais its prewritten code from a *.pri file they just run qmake and compile.
The file is actually libqtscript_network.so and strings told me the handy :
qt.network for this but this didnt work in this case for some reason.
Cheers,
Andreas Marschke.
More information about the Kde-bindings
mailing list