On 17/12/2010, at 11:54 PM, ext Ville M. Vainio wrote:
> Currently, you cannot store javascript objects as properties in qml
> components, e.g. you can't do
>
> propery JSRef myobj
>
> function setCallback(f) { myobj = f };
>
> On irc #qt-qml, this explanation was quoted:
>
> QQQ
> In QML "property var" cannot store JavaScript native objects, as we
> cannot bind to them. This might change in a future release. For now,
> more explicit warnings are generated when you accidentally do this.
> QQQ
The core problem is that properties on a JS object don't give any notification
when they are changed (in contrast to a QObject, which uses NOTIFY signals to
inform when a property has changed). This means if you bind to such a property,
e.g.
Text { text: myobj.textProp }
the binding will *not* be updated if you do something like
function myFunction() { myobj.textProp = "New Text" }
This is the reason we don't currently support it -- we didn't want to make it
possible for these bindings to "silently fail" (and from memory providing a
warning for such bindings was also non-trivial).
> I can't claim to understand the explanation, but I'm curious whether
> we will have this feature in the near future - as the lack of it seems
> to be a pretty fundamental shortcoming in QML, and workarounds (like
> storing the reference in a .js file, or using C++) seem quite hacky in
> comparison.
We certainly want to make JS/QML integration more seamless, but I'm not sure
exactly how or when this will happen. It's not currently planned as part of the
next release (QtQuick 1.1).
Regards,
Michael
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml