Highlight of an ListView



  • Hi, I'm using a ListView wich is shown in an Rectangle an have a problem with the quantity of shown ListModelElements.

    My ListModel includes 8 elements but I only want to show 4 of them.

    @
    Rectangle {
    width: 340
    height: 339

    ListView {
    ...

    delegate: Component {
    Item {
    width: 340
    height: 85
    }
    }

    }
    }
    @

    My First problem, I want to show 4 Items. 4* 85 = 340. But when I use height 340 instead of 339 for my Rectangle then always 5 elements shown.
    Is using height 339 the best way to show only 4 Elements?

    Second Problem is, when at start only 4 Elements shown and I navigate the highlight to the fourth Element, then the fifth Element is shown automatically.
    Is it possible to prevent this?

    I use Qt 5 alpha and QtQuick 2.0.

    Thank You for your help.



  • By default no item in QtQuick clips its content. In the case of views, this means that delegates outside the area of the view may be visible. You can solve this by setting 'clip: true' on the ListView. You can then set the height to 340, and this will fix the scrolling issue when the 4th element becomes the currentItem.



  • It works,

    Thank you very much.


Log in to reply
 

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