How to make a JS property assigned a function?
-
Hi ,
I recently meet a problem, which is how define a property in C++ file and in js file it could be assigned to a function.
mainview.h
@
#define XXX QScriptValue
class MyView : public QObject{
Q_OBJECT
Q_PROPERTY(QScriptValue value READ getValue WRITE setValue SCRIPTABLE true);public slots: XXX getValue() const; void setValue(const XXX &a); };
@
js file:
@
var app1 = document.getElementById("app1");
app1.value= funcTest;function funcTest(abc) {
var j = 12345;
alert(abc);
}
@
Now I found that, if I use "QString" in Q_PROPERTY(QString value READ getValue WRITE setValue SCRIPTABLE true), the function funcTest could be assinged, but how could this function funcTest be called?
And in
@
void setValue(const XXX &a);};
@
"a" could be recognized as a function.Could anyone could help me with this problem?
Thank you!Edit: please use @ tags around code sections; Andre