[Qt-qml] 'property variant' mutilates / can't store a javascript object with js prototype?
Ville M. Vainio
vivainio at gmail.com
Tue Oct 26 13:58:54 CEST 2010
I'm trying to store a javascript object with 'prototype' in property variant.
In my qml I have
import "redditengine.js" as RE
Rectangle {
...
property variant eng
Component.onCompleted: eng = RE.create()
My javascript is here:
http://gitorious.org/qmlreddit/qmlreddit/blobs/master/qml/qmlreddit/redditengine.js
(It's perfectly normal javascript that follows GJS convention to
create a javascript "class" RedditEngine)
It appears that the object I create with "new RedditEngine" works
perfectly fine before I store it to "property variant eng" (i.e. it
works inside RE.create()), but once it's stored the attributes in
prototype are forgotten (or "sliced out").
You can check out and run the code from gitorious, but for reference
here are the attributes (as given by dump() in my js file) before I
store the Object to property variant:
Property currentlink : dummy 2
Property linkSelected : function (link) { ... }
Property _init : function () { ...}
And here they are once I shove it to property variant and try to use it again:
Property currentlink : dummy 2
That is, it appears everything not immediately in the concrete object
is discarded.
When I try to just call linkSelected I get this:
file:///scratchbox/users/ville/home/ville/qmlreddit/qml/qmlreddit/redditengine.js:38:
TypeError: Result of expression 'eng.linkSelected' [undefined] is not
a function.
Should I file a bug, or discover some other place to store my javascript object?
--
Ville M. Vainio @@ Forum Nokia
More information about the Qt-qml
mailing list