Search code examples
c++qtqt4qt5qtreewidgetitem

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?


Solution

  • QAbstractItemView::ExtendedSelection should provide the expected behaviour.

    [Moved from comment to provide an acceptable answer.]