KidNg
KidNg

Reputation: 305

Horizontal listview display over its boundary

I create a Rectangle to wrap the horizontal listview, but it displays over its boundary. The problem like below image: enter image description here In this image, the listview display the item infront and below of current display item. How can display only the current item at that time and When user swipe the listview, the item change by one item?

My source code here:

ApplicationWindow {
visible: true
width: 900
height: 480
title: qsTr("Hello World")

Rectangle{
    id: bound
    anchors.fill: parent
    color: "blue"
}

Rectangle{
    id: listview
    width: 300
    height: 300
    anchors.centerIn: parent
    color: "red"
    ListView{
        id:lst
        width: 250
        height: 250
        orientation: ListView.Horizontal
        snapMode: ListView.SnapOneItem
        //preferredHighlightBegin: 0
        //preferredHighlightEnd: 200
        highlightRangeMode: ListView.StrictlyEnforceRange
        boundsBehavior: Flickable.StopAtBounds
        highlightFollowsCurrentItem: true
        keyNavigationWraps: true
        interactive: true
        model: 10
        delegate: Rectangle{
            id: dele
            width: 250
            height: 250
            anchors.centerIn: listview
            color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
        }
    }
}

}

Upvotes: 0

Views: 433

Answers (1)

jpnurmi
jpnurmi

Reputation: 5836

ListView does not clip by default. You can set clip: true in cases when it is needed. More details: http://doc.qt.io/qt-5/qtquick-performance.html#clipping

Upvotes: 2

Related Questions