How to limit and repeat the items in a QML List View



  • Hi,

    I have a model which basically contains some integers (say 1 to 10). I want my list view to show only 3 items ( one highlighted, one above and one below). How do i achieve this? Next, imagine that the view is flicked and the last item is visible..on further flicking i want the first item to become visible again...i.e the data in the model is repeated from the beginning.

    I am not sure how to achieve this and any hints will be appreciated.

    thanks,
    max



  • Hi max,

    To limit your view to show just 3 items, you can try to use a delegate Item which takes 1/3 from the ListView's height.
    For the other stuff I don't have an idea at this point, but it is something I would also like to know :)

    Regards,
    Wladek



  • You should take a look at PathView instead. I think the PathView wraps when "flicking" and I also think that you can specify the number of visible items with 'pathItemCount'.



  • i will try PathView but i would nonetheless appreciate an answer that uses a ListView.



  • Hi,

    ListView in Qt Quick 1 doesn't have built-in support for "infinite"/wrapping lists, so as mario indicated the standard advice in this situation is to try PathView.

    Another approach might be to try manipulating the model -- maybe it would work to add items to the end of the model (and remove some from the beginning) when you got near the end of the list? I'd be very interested to hear if you (or others) were able to get something working with ListView.

    Regards,
    Michael



  • It is also unfortunate that the API's for the model-view stuff in QML are private. Otherwise, you would be able to write your own view that implements this. I hope that Quick 2 will change that too.



  • using path view + path line did the trick for me..but as andre pointed out, it will be nice if we could reimplement statndard views.
    @mbrasser : i will try manipulating the model and see if it works..



  • If anyone has ever figured out how to make a QML PathView repeat the items in the list when the visible items are greater than the list count, that information would be appreciated. Thanks.
    #bump


Log in to reply
 

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