enum QAbstractItemView::SelectionMode:
QAbstractItemView::ExtendedSelection 设定该模式,在ui上鼠标点击等操作展现为多选,但是如果在代码里使用类似selectRow等函数无法实现多选--每次执行selectRow都会将之前selected的清掉,最终反应是单选,如果在代码里要多选可以将其临时设定成QAbstractItemView::MultiSelection。
Constant | Value | Description |
---|---|---|
QAbstractItemView::SingleSelection | 1 | When the user selects an item, any already-selected item becomes unselected. It is possible for the user to deselect the selected item by pressing the Ctrl key when clicking the selected item. |
QAbstractItemView::ContiguousSelection | 4 | When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. |
QAbstractItemView::ExtendedSelection | 3 | When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. Multiple items can be selected by dragging the mouse over them. |
QAbstractItemView::MultiSelection | 2 | When the user selects an item in the usual way, the selection status of that item is toggled and the other items are left alone. Multiple items can be toggled by dragging the mouse over them. |
QAbstractItemView::NoSelection | 0 | Items cannot be selected. |