1
votes

I want to have two list views followed by one another in a big ScrollView, say because they have slightly different delegates. So a layout is like this:

Layout with two list views in a scroll view]

Unfortunately ListView type is also a flickable, so it doesn't present all its content in a flat list suitable for having inside a scroll view. So how do I do this with Qt Quick views?

I've tried a trick: I can resize list views like this:

    ListView {
        id: list1

        height: contentHeight + spacing * count

        model: superModel
        delegate: delegate1
    }

Unfortunately, aside from being a dirty hack and leaving an unneccesary flickable grabbing my clicks, it doesn't really work: content just doesn't fit as there are still top and bottom margins I don't know the value of.

1

1 Answers

1
votes

You should use a ColumnLayout with two Repeater's in a ScrollView (or Flickable if you like)

ScrollView {
    contentWidth: width   //maybe you don't need this

    ColumnLayout {
        width: parent.width   //maybe you don't need this

        Repeater {
            model: superModel1
            delegate: delegate1
        }

        Repeater {
            model: superModel2
            delegate: delegate2
        }
    }
}

Since you didn't show the delegate, you might need minor tweaking of implicitHeight and/or implicitWidth.