I am currently working on this topic: http://doc.qt.nokia.com/4.7-snapshot...it-bridge.html
So I am wondering how to return a JS object to JS environment? Is there an example?
I am currently working on this topic: http://doc.qt.nokia.com/4.7-snapshot...it-bridge.html
So I am wondering how to return a JS object to JS environment? Is there an example?
Last edited by cysin; 27th November 2010 at 13:14. Reason: typo
what you mean elaborate? I need some details about how to return an object, better with an example
The description of your problem is unclear. Elaborate on the problem please.
Sorry my English is not that good.
I am currently adding an object like this
Qt Code:
To copy to clipboard, switch view to plain text mode
So I can access C++ class from Javascript environment. And also I want this class could return an object.
Let's say, the C++ class has a function called "getItem()", so I can access this function using Javascript:
Qt Code:
var item = myjsobj.getItem(); alert(item.getName()); alert(item.getPrice());To copy to clipboard, switch view to plain text mode
I want "getItem()" function to return another object, this object might be dynamically generated.
Thank you~
Last edited by cysin; 28th November 2010 at 02:22. Reason: typo
Ok but what is it exactly that you tried and didn't work? I still fail to see the problem...
Qt Code:
QObjectList pcp::getObjectArray() { js_pqm* pqm1 = new js_pqm(w); js_pqm* pqm2 = new js_pqm(w); QObjectList objArray; objArray.push_back(pqm1); objArray.push_back(pqm2); return objArray; }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
There is an automatic mapping scheme between Qt/C++ types and javascript types. See the page you quoted in your first post for details.
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.
Bookmarks