PDA

View Full Version : Hide ListView items when not in bounds



adutzu89
26th October 2016, 18:54
Is there a way to hide the elements which past the visible view in ListView?
At the moment they go pass the header item and over another item before the header.


ListView {
id: searchList
anchors.top: searchFieldBottomBorder.bottom
anchors.topMargin: 20
anchors.left: parent.left
anchors.leftMargin: (parent.width - width) / 2
width: searchField.width
height: (body.height - title.height - searchField.height - 100)
cacheBuffer: 0
header: Rectangle {
height: 50
width: searchList.width
color: "transparent"
Text {
text: "Select Location"
color: "#ffffff"
font.pixelSize: 18
anchors.fill: parent
verticalAlignment: Qt.AlignVCenter
}
}
headerPositioning: ListView.OverlayHeader

delegate: Rectangle {
height: 40
width: searchList.width
color: "transparent"
Text {
text: modelData
color: "#ffffff"
font.pixelSize: 18
anchors.fill: parent
verticalAlignment: Qt.AlignVCenter
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
}
}
}

Qt version: 5.6.2

anda_skoa
26th October 2016, 20:55
Enable clipping



clip: true


Cheers,
_