Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    How to make a JS property assigned a function?

    General and Desktop
    1
    1
    1000
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yl28365 last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post