Results 1 to 10 of 10

Thread: How to return a Javascript object to Javascript environment?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    5

    Default Re: How to return a Javascript object to Javascript environment?

    Quote Originally Posted by wysota View Post
    Ok but what is it exactly that you tried and didn't work? I still fail to see the problem...
    Qt Code:
    1. QObjectList pcp::getObjectArray() {
    2. js_pqm* pqm1 = new js_pqm(w);
    3. pqm1->setObjectName(QString("iampqm1"));
    4. js_pqm* pqm2 = new js_pqm(w);
    5. pqm2->setObjectName(QString("iampqm2"));
    6. QObjectList objArray;
    7. objArray.push_back(pqm1);
    8. objArray.push_back(pqm2);
    9. return objArray;
    10. }
    To copy to clipboard, switch view to plain text mode 

    This is a function of the C++ class that maps to javascript array. I want this function to return a javascript array that contains javascript object. but it failed to recongnize the returned 'QObjectList', said "TypeError: cannot call getObjectArray(): unknown type `QObjectList' on line:35

    So I am wondering what Qt type this function should return to make JS engine recognize them correctly

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to return a Javascript object to Javascript environment?

    There is an automatic mapping scheme between Qt/C++ types and javascript types. See the page you quoted in your first post for details.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2010
    Posts
    5

    Default Re: How to return a Javascript object to Javascript environment?

    Quote Originally Posted by wysota View Post
    There is an automatic mapping scheme between Qt/C++ types and javascript types. See the page you quoted in your first post for details.
    But, what's wrong with my posted code? It should return an array contains objects

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to return a Javascript object to Javascript environment?

    It's likely that something is not registered somewhere. It's really hard to say anything useful if you just keep sending unrelated pieces of code. Provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Mapping JavaScript object to QT (and vice versa)
    By leoalvesmachado in forum Newbie
    Replies: 2
    Last Post: 30th June 2010, 19:00
  2. javascript problem
    By bmn in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2009, 13:40
  3. Replies: 3
    Last Post: 14th October 2008, 21:04
  4. Javascript
    By ale301168 in forum Qt Programming
    Replies: 0
    Last Post: 6th September 2008, 23:23
  5. JavaScript in QTextBrowser
    By manojmka in forum Qt Programming
    Replies: 4
    Last Post: 27th December 2007, 08:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.