[Qt-qml] Getting access to QML objects from a workerscript
Sivan Greenberg
sivan at omniqueue.com
Mon Oct 10 19:18:42 CEST 2011
Okay, re-reading this again, it seems you must serialize the object to
pass it to the worker script (the standard way of transmittable object
notation in js) which actually means you need to do something like
JSON.stringify or somesuch and JSON.parse it back to the object form
in your worker script.
Hope this helps and that it is correct :)
-Sivan
On Mon, Oct 10, 2011 at 7:16 PM, Sivan Greenberg <sivan at omniqueue.com> wrote:
> Hi Ronan!
>
> On Mon, Oct 10, 2011 at 5:50 PM, <ronan.maclaverty at nokia.com> wrote:
>
>> Player.myplayer = player
>> workThread.sendMessage( {} );
>>
>> The WorkScript.onMessage function cannot access player.
>>
>> I am sure that I have missed some crucial piece of documentation somewhere, but any help solving this issue would help.
>>
>
> In http://doc.qt.nokia.com/4.7-snapshot/qml-workerscript.html#sendMessage-method
> , it is said:
> "The message object may only contain values of the following types:
> boolean, number, string
> JavaScript objects and arrays
> ListModel objects (any other type of QObject* is not allowed)
> All objects and arrays are copied to the message. With the exception
> of ListModel objects, any modifications by the other thread to an
> object passed in message will not be reflected in the original
> object."
>
> Could this be causing your problems? I have no experience myself with
> WorkerScript, however I know from other similar systems there is quite
> some constraints on the "messages" you can pass as objects to other
> context to be run in parallel...
>
> If this is not the issue, I will be also quite curious to know how to
> do something like this, how to pass the instances properly for
> processing, consider Python's Queue.Queue module and multiprocessing.
>
> -Sivan
>
--
-Sivan
More information about the Qt-qml
mailing list