[GCompris-devel] Needs help on javascript/qml binding

Emmanuel Charruau echarruau at gmail.com
Sun Oct 25 13:50:50 UTC 2015


Hi,

JJohnny pointed me that I could use the handler onCompleted to bind my qml
item and my javascript.
I still have a problem.
When I run the program, it seems to never reach this handler and displays:

TypeError: Cannot read property 'myFlow1' of undefined


Undefined should be mySentenceItems

   sentenceItemComponent.createObject(
                                mySentenceItems.myFlow1, {
                                    "sentenceSegments": sentenceSegments
                                })

and I define it line 59 from
https://github.com/allon49/GCompris-qt/blob/master/src/activities/multiple_choices_sentences/multiple_choices_sentences.js

and I set it line 42 from
https://github.com/allon49/GCompris-qt/blob/master/src/activities/multiple_choices_sentences/SentenceItem.qml

But since it does not seem to go up to the onCompleted handler, there must
be an additional trick.
It seems that I can not put it in an OnStart handler as there is no start
signal attached to a simple item.

Any help?

Thanks,

Emmanuel












2015-10-24 13:23 GMT+02:00 Emmanuel Charruau <echarruau at gmail.com>:

> Hi everybody,
>
> I have started a new activity based on babymatch. The activity is a
> multiple choices activity based on sentences and words.
> I display a sentence and mutiple choices items for the kid to choose
> between answers.
>
> I have done a prototype in qml displaying a sentence in a flow.
> This sentence is made of different types of words. Words that are plain
> text (just there to show a normal sentence); words that will be show in
> color as they will have to be analysed by the user, and finally mutiple
> choices words.
> That works.
>
> This prototype can be found here:
>
> https://github.com/allon49/GCompris-qt/blob/41d6cdae0f036dac0f4f1a0f7fa59b89612def00/src/activities/multiple_choices_sentences/TextItem.qml
> .
>
> Now I want to implement the same thing using javascript, but I am not able
> to associate the items components I create to the flow element contained in
> my element SentenceItem.qml
>
> I can see how the babyshape author has done this in the main qml file
> mutiple_choices_sentences.qml using "QtObject { id: items property alias".
> But I don't see how to apply it to my element SentenceItem.qml as I don't
> know how to create an equivalent to "items" which is set using onStart: {
> Activity.start(items, url, levelCount, answerGlow, displayDropCircle) } in
> multiple_choices_sentences.qml.
>
> the code can be found here
>
> https://github.com/allon49/GCompris-qt/tree/41d6cdae0f036dac0f4f1a0f7fa59b89612def00/src/activities/multiple_choices_sentences
>
> Thanks a lot for you help if you can as I have no idea how to go over this
> problem.
>
>
> Regards,
>
> Emmanuel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/gcompris-devel/attachments/20151025/d940231d/attachment.html>


More information about the GCompris-devel mailing list