Added class ScriptFunctionWrapper to allow QML-scripts to call functions in our normal scripts

This commit is contained in:
Micke Prag 2010-12-17 15:18:02 +00:00
parent b6581e2380
commit a9b68f553e
6 changed files with 69 additions and 10 deletions

View file

@ -0,0 +1,23 @@
#include "scriptfunctionwrapper.h"
class ScriptFunctionWrapper::PrivateData {
public:
QScriptValue object;
QString name;
};
ScriptFunctionWrapper::ScriptFunctionWrapper(const QScriptValue &object, const QString &name, QObject *parent) :
QObject(parent)
{
d = new PrivateData;
d->object = object;
d->name = name;
}
ScriptFunctionWrapper::~ScriptFunctionWrapper() {
delete d;
}
QVariant ScriptFunctionWrapper::call() {
return d->object.property(d->name).call().toVariant();
}