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.

    #define XXX QScriptValue
    class MyView : public QObject{
    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;
    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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.