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

Johnny Jazeix jazeix at gmail.com
Sun Oct 25 15:13:06 UTC 2015


Hi,

Disclaimer: I can't test so I'm only doing assumption on your code.

What I understand is that you are trying to create a SentenceItem
object with parent a Flow created in this item (which is not yet
created).
I think the flow should be outside this item, else anytime you create
an item, the flow in the js will be changed and the items won't be
added to the same flow.

Johnny

ps: the while loop
(https://github.com/allon49/GCompris-qt/blob/master/src/activities/multiple_choices_sentences/multiple_choices_sentences.js#L129)
decrements levelDataLength which is used as modulo just below, is it
normal ?


2015-10-25 14:50 GMT+01:00 Emmanuel Charruau <echarruau at gmail.com>:
> 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
>>
>>
>
>
> _______________________________________________
> GCompris-devel mailing list
> GCompris-devel at kde.org
> https://mail.kde.org/mailman/listinfo/gcompris-devel
>


More information about the GCompris-devel mailing list