mr_beginner
mr_beginner

Reputation: 145

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.

Upvotes: 5

Views: 1205

Answers (1)

Vishal Kumar
Vishal Kumar

Reputation: 102

Use ExtendedSelection rather than Multiselection.

tree.setSelectionMode(QAbstractItemView.ExtendedSelection)

Upvotes: 3

Related Questions