"Unselect" current item in ListView



  • I would like to "unselect" the current item in a ListView, for example, after the creation of the ListView or when the ListView loses its focus. If I set currentIndex < 0 the ListView selects (highlights) the first item, but if I set currentIndex >= count it "unselects" the selected item (removes the highlight).

    Is this really the correct behavior for the ListView (the docs say nothing about it)?



  • Try

    @MyListView->selectionModel()->clearSelection();@



  • Hi,

    That doesn't sound like intended behavior to me. Could you please raise a bug in the "bugtracker":http://bugreports.qt.nokia.com? ListView should probably also provide a clearSelection() function or something similar.

    Regards,
    Michael



  • @Vass: I think that this will only apply to Widget ListViews and not Quick ListViews. Quick ListViews have no selectionModel-method.

    @mbrasser: Done!



  • how about trying on getting the selected item in list view and then

    selectedItem->setSelection() for required operation.



  • [quote author="aviral" date="1280731394"]how about trying on getting the selected item in list view and then

    selectedItem->setSelection() for required operation.[/quote]

    But I don't think I can do that in QML?


Log in to reply
 

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