[Interest] QML StackView fragility (Interest Digest, Vol 39, Issue 14)

Harri Pasanen harri at mpaja.com
Tue Dec 9 21:43:37 CET 2014


Good suggestion, unfortunately it did not help.

I made a nice generic loader mod that can be used for any page, like:

     Loader {
         id: qmlLoader
         property var _cb: null

         function open(pageSrc, callback)
         {
             _cb = callback
             source = pageSrc
         }

         onStatusChanged:
         {
             if (status == Loader.Ready && _cb)
                 _cb(item)
         }
     }

And in the usage would be

      qmlLoader.open("qrc:/qml/HelpPage.qml",
                                    function (page) { 
console.log('opening', page); page.openHelp('test') })

Still keeps failing for a one particular page when *leaving* it via 
StackView.push()
Not using the loader makes it work.

Harri






On 06/12/2014 15:31, Jérôme Godbout wrote:
> Hi, you may want to split your work into 2 step, set the source, wait for the status to be Loader.Ready before using the item.
>
> onClicked:
> {
>>    qmlLoader.source = ‘qrc:/qml/HelpPage.qml’;
> }
>
> Loader
> {
>    onStatusChanged:
>    {
>       if(status == Loader.Ready)
>       {
>          helpPage.open(helpContext);
>          qmlLoader.item.open(helpContext);
>        }
>    }
> }
>
> The loader is asynchronous, you can check if it’sready right away, but I suggest you do wait for it to changed. Hope this help.
> Jerome
>
>> On Dec 6, 2014, at 7:00 AM, Harri Pasanen <harri at mpaja.com> wrote:
>>
>> Found out more about the StackView issue.
>> It seems that Loader interacts badly with it, so now I'm not using the
>> loader.
>>
>>          onClicked: helpPage.open(helpContext)
>> // StackView blows up sometimes if the following loader is used.
>> //            qmlLoader.source = "qrc:/qml/HelpPage.qml"
>> //            qmlLoader.item.open(helpContext)
>>
>> Strangely enough, the commented out code path works about 9 times out of 10.
>>
>> I may try to distill a test case out of this at some point, but now at
>> least this is something to lookout for in case someone else runs into it.
>>
>> (HelpPage.qml above was the page C below, A->C ran the exact same code,
>> so the issue was B, the leaving page somehow got null in the transition.)
>>
>>
>> On 05/12/2014 23:41, Harri Pasanen wrote:
>>> StackView blows up for me from time to time for no apparent reason.
>>> No I seem to have a reproducible issus.
>>>
>>>
>>> I have pages A->B->C
>>>
>>>
>>>  From A I do push(B) to got to B, and all is fine.
>>>
>>> But when I do push(C) it blows up:
>>>
>>>
>>> file:///home/harri/Qt5.4.0/5.4/gcc_64/qml/QtQuick/Controls/Private/StackViewSlideDelegate.qml:79:
>>> TypeError: Cannot read property 'width' of null
>>>
>>> file:///home/harri/Qt5.4.0/5.4/gcc_64/qml/QtQuick/Controls/StackView.qml:891:
>>> TypeError: Type error
>>>
>>> file:///home/harri/Qt5.4.0/5.4/gcc_64/qml/QtQuick/Controls/StackView.qml:902:
>>> TypeError: Property 'complete' of object TypeError: Type error is not
>>> a function
>>>
>>>
>>> At that point page C is visible, but non-functional due to above errors.
>>>
>>>
>>> But looking at StackViewSlideDelegate.qml I don't see anything
>>> obviously wrong there,
>>>
>>> the underlying model seems to fail for some reason.
>>>
>>>
>>>
>>> Any ideas?
>>>
>>>
>>> Harri
>>>
>>>
>>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list