That obviously can't be done from a worker thread.
Yes, more or less. You can't pass the same object but you can send a copy of the data.My understanding of scripting is limited, so you are saying I can create an object inside the script pass it back to my c++ as a QScriptValue and then pass that back to the other script as an argument?
There are many ways to do it but you can start with:If that is true that would be exactly what I needed, will just need to figure out the creation syntax for an object inside a script and setting its variables and returning it.
javascript Code:
var x = new Object; x.something = somethingelse; x.xyz = abc; return x;To copy to clipboard, switch view to plain text mode
Yes, that's one possibility. But you can't pass the same value to another engine, you have to copy the data from it to a new object that is bound to the other engine.Looks like I could do something like
That should return the myObject as a QScriptValue that I can pass as an argument to the other script?Qt Code:
function foo() { myObject = new Object(); myObject.a = 1; myObject.b = 2; return myObject; }To copy to clipboard, switch view to plain text mode
JavaScript Object and QObject are two different things. QObjects are modelled as Objects but you can't convert freely between the two (i.e. you can't "cast" Object to QObject).
You can't reference GUI from non-GUI threads. As for making objects visible to the script, consult the reference manual, there are at least three ways to do it.EDIT: and past that how to pass both the ui and the script object.
Bookmarks