Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable multipleselection in qtreeview till ctrl key is pressed in pyqt5?

I have a qtreeview, in which i want to enable mulitple row selection only when ctrl key is pressed . For multiple row selection i was using setSelectionMode(QAbstractItemView.MultiSelection) But found out that it looks odd means if i simply clicked a item it get selected. I don't want that. I want to select multiple rows selection only when ctrl is pressed.

like image 230
mr_beginner Avatar asked Oct 29 '22 20:10

mr_beginner


1 Answers

Use ExtendedSelection rather than Multiselection.

tree.setSelectionMode(QAbstractItemView.ExtendedSelection)
like image 148
Vishal Kumar Avatar answered Dec 05 '22 03:12

Vishal Kumar