ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #17868
Re: [QML] TypeError on delegate remove
On Thu, Jan 28, 2016 at 9:37 AM, Sam Bull <sam.hacking@xxxxxxxx> wrote:
> I have a custom component used as a delegate in a ListView. When this
> object is removed I get the error:
>
> TypeError: Cannot read property of null
>
> This is occurring on the rather standard line:
>
> anchors { left: parent.left; right: parent.right }
>
> So, how am I supposed to clean up this error? The only thing I can
> think of, is a hacky looking bit of code like:
>
> anchors { left: (index == -1) ? 0 : parent.left; right: (index ==
> -1) ? 0 : parent.right }
Try:
anchors {
left: parent ? parent.left : undefined
right: parent ? parent.right : undefined
}
HTH,
Olivier
Follow ups
References