How to clear the selection of QListView when multiple items are selected?

后端 未结 2 1359

I am working on a Qt App where I have a QListView. There are few items present in the list. My application requires items to be rearranged according to user\'s choice. Every

相关标签:
2条回答
  • 2021-01-20 11:56

    Use the QAbstractItemView::clearSelection function.

    If you have subclassed QListView you can just call it with clearSelection();

    0 讨论(0)
  • 2021-01-20 12:12

    Use

    void QAbstractItemView::clearSelection() [slot]
    

    to clear selection

    Also, all views have a selection model you can access through:

    QItemSelectionModel * QAbstractItemView::selectionModel() const
    

    that allows doing a lot more things selecting

    Look at Handling selections in item views

    Another thing ...

    #ifdef QT_NO_DEBUG
    

    means release

    #ifndef QT_NO_DEBUG
    

    would be debug mode, and im sure, it will not compile the code you pasted

    0 讨论(0)
提交回复
热议问题