QML ListView draws ObjectModel outside of its bounds

I am trying to log into QT / QML from WPF / XAML.

In a test GUI, I am using a ListView to display different models at the click of a button. This works well so far, the view keeps showing each model when I click the corresponding button. But it still draws all other models outside of its boundaries, overlapping the surrounding elements. Can I disable this behavior?

This is my ListView:

ListView
{
    id: list_view

    anchors.fill:                   parent
    model:                          main_view_model
    snapMode:                       ListView.SnapOneItem
    boundsBehavior:                 Flickable.StopAtBounds
    highlightFollowsCurrentItem:    true
    highlightMoveDuration:          75
    highlightRangeMode:             ListView.StrictlyEnforceRange
    currentIndex:                   view_index
}

      

And this is the ObjectModel:

ObjectModel
{
    id: main_view_model

    // ListView index 0
    TestView1
    {
        anchors.centerIn: parent.center
        width: list_view.width
        height: list_view.height
    }

    // ListView index 1
    TestView2
    {
        anchors.centerIn: parent.center
        width: list_view.width
        height: list_view.height
    }

    // ListView index 2
    TestView3
    {
        anchors.centerIn: parent.center
        width: list_view.width
        height: list_view.height
    }

    // ListView index 3
    TestView4
    {
        anchors.centerIn: parent.center
        width: list_view.width
        height: list_view.height
    }
}

      

I'm still struggling a little with layout and QML concepts as I'm used to XAML. So please excuse me if I make an obvious mistake.

+3


source to share


1 answer


It looks like the "clip" property of the Item element will help you: Item.clip



+7


source







All Articles