← Back to team overview

ubuntu-phone team mailing list archive

Re: [qml] anchors.fill error in ListView

 

On Saturday 21 September 2013 13:00:38 Sam Bull wrote:
> I am receiving an error when running my app, about using anchors.fill.
> If I replace anchors.fill with left and right anchors only, then the
> ListView only displays one item. Is there a way to make the code work
> AND get rid of the error? I only seem to be able to do one or the other.
> The error and relevant snippet of code are below.
> 
>         QML Column: Cannot specify top, bottom, verticalCenter, fill or
>         centerIn anchors for items inside Column. Column will not
>         function.
> 
>         Column {
>             anchors.fill: parent
> 
>             ListView {
>                 anchors.fill: parent
>                 model: addresses
> 
>                 delegate: ListItem.Standard {
>                     text: address
>                     onClicked: print("Address")
>                     enabled: false
>                 }
>             }
>         }


Hi,

as the error message states, you cannot use top and bottom anchors inside a 
Column. After all, that doesn't make anyways. The Column is an invisible 
element which aligns the items inside in a column, hence moving them up and 
down inside the Column. Manually setting a top/bottom anchor point or some y 
value is conflicting with what the the Column should do for you. If you want 
something to be anchored at the top and the bottom like in this example, just 
drop the Column.

Hope this helps to understand,
Michael


References