Comment 2 for bug 1124071

Revision history for this message
Timo Eskola (timo-tolleri) wrote : Re: Cannot add Tabs programmatically

It would be nice to be able use ListModel instead of VisualItemModel. You can do this with with a ListView.

    ListModel {
        id: pageModel

        ListElement {
            title: "Page 1"
            page: "TextPage.qml"
        }
        ListElement {
            title: "Page 2"
            page: "ListPage.qml"
        }
        ListElement {
            title: "Page 3"
            page: "WebPage.qml"
        }
    }

    ListView {
        id: pager
        anchors { fill: parent; topMargin: parent.indicatorHeight}
        model: root.pageModel
        delegate: Loader {
            width: pager.width
            height: pager.height
            source: page
        }
        preferredHighlightBegin: 0
        preferredHighlightEnd: 0
        highlightRangeMode: ListView.StrictlyEnforceRange
        orientation: ListView.Horizontal
        snapMode: ListView.SnapOneItem
    }