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

Jérôme Godbout jerome at bodycad.com
Sat Dec 6 15:31:44 CET 2014


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