Item visibylity in a ListView



  • Hi everyone,

    When using a ListView, items that are not supposed to be displayed ( out of the ListView area ) are still visible if the listview is on top of everything else ( qml elements ).

    Here is a little bit of code to understand the issue ( not all parameters are set, it is just for understanding ) :
    @
    Item
    {
    id: mainWindows
    width: 200
    height: 800
    Rectangle
    {
    id: listViewHolder
    width: parent.width * 0.9
    height: parent.height * 0.9
    color: "white"
    ListView
    {
    id: myListView
    width: parent.width - 10
    height: parent.height - 10
    model: aModel
    delegate: aDelegate
    }
    }
    DropShadow
    {
    anchors.fill: listViewHolder
    source: listViewHolder
    color: "black"
    }
    }
    @

    What happens is that when I have more items to display ( in height ) than the list view can contains, they are visible in the listViewHolder and in the mainWindow. It messes up the DropShadow and it really ugly to watch.
    Is there any way to tell the list view to make those items disappear or do I have to handle this myself in the delegate ?



  • you should set "clip: true" in your ListView or Rectangle (that is a property of the Item base object, check out the doc) :)



  • Thanks it works..I knew about that property but never thought of using it..


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.