Hi,

Den 02. des. 2010 23:50, skrev ext Bart Kelsey:
> I've attached a small test case that demonstrates the issue.  Note 
> that when the Object gets passed from QtScript to QML, it makes a copy 
> instead of passing a reference.
>
> Thanks for your help,
> Bart
>
>
> On Thu, Dec 2, 2010 at 1:43 PM, Bart Kelsey <elba...@gmail.com 
> <mailto:elba...@gmail.com>> wrote:
>
>     Sorry I didn't reply to this earlier... somehow I managed to miss
>     it.  I'll do my best to reduce this issue down to a test case and
>     then contact you with it when I do.
>
>     Thanks for your help!
>
>     Bart
>
>
>
>     On Tue, Nov 30, 2010 at 3:47 AM, Kent Hansen
>     <kent.han...@nokia.com <mailto:kent.han...@nokia.com>> wrote:
>
>         Hi,
>
>         Den 29. nov. 2010 15:54, skrev ext Bart Kelsey:
>         > My current project is a game engine that uses QML for the UI and
>         > QtScript for game scripting (video at
>         > http://www.youtube.com/watch?v=SG5p-qLARrw ).  At any rate,
>         while it's
>         > possible to call functions on QML elements from QtScript,
>         when I try
>         > to pass an object to that function (even a
>         QDeclarativeItem), it gets
>         > mangled into a QVariantMap (as opposed to a reference to the
>         actual
>         > object that I passed, which is what I need).  Why is this?
>          Is there
>         > any way I can stop it from happening and pass the object as
>         a reference?
>
>         Could you provide a small compileable application that
>         demonstrates the
>         issue?
>
>         Kent
>

Please keep this thread on the mailing list.
QML has its own script engine internally. You can't pass an object 
reference from one script engine (yours) to another (QML's).
In any case, what's happening here is that for the following QML

Rectangle {
     function foo(arg) { }
}

the implementation will create a meta-object that contains a function 
with signature

foo(QVariant)

When you pass a script object to this function, QtScript will try to 
convert the argument to a variant. The default behavior is to call 
QScriptValue::toVariant(), which converts the object to a QVariantMap.

Regards,
Kent

_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to