Search code examples
qtqlistview

How to loop QListView item selection


How can I make QListView item selection loop from bottom item to top (by pressing navigation key, down) and from top item to bottom (by pressing navigation key, up)? Is there a flag to be defined or some other way? My listview is in IconMode I wanted the selection to go to next row's 1st item when I've reached the end of a row.

Thanks


Solution

  • Its Default behavior provided by the list view for iconic mode. in order to achieve your requirement, you need to handle it manually.

    i.e you will be having the count of items in a row, once you reach the last item handle the right navigation key press event, then focus it back to the first element of the same row..

    to get the navigation keypress event, either you install event filter or ovveride the keypress event function.