Onur Tuna
Onur Tuna

Reputation: 1060

QTreeWidgetItem multiple selection using keyboard

I have a QTreeWidgetItem. I am able to set a multiple selection mode using setSelectionMode(QAbstractItemView::MultipleSelection). In this case the user is able to select the items without using keyboard. When one clicks on an item it has become selected.

How can I make it selectable only using CTRL or Shift?

Upvotes: 1

Views: 739

Answers (2)

Murphy
Murphy

Reputation: 3999

QAbstractItemView::ExtendedSelection should provide the expected behaviour.

[Moved from comment to provide an acceptable answer.]

Upvotes: 3

Aaron
Aaron

Reputation: 1191

If you don't need any mouse interaction with the items, you may try item->setAttribute( Qt::WA_TransparentForMouseEvents );

Upvotes: 1

Related Questions