Multiple Selection QTreeWidget

此生再无相见时 提交于 2019-12-05 14:05:16

问题


Does anyone know if its possible to select multiple items on a QTreeWidget and how to go about enabling the multiple selection?

All the items I want to be selectable are top level QTreeWidgetItems and all their children are set to be disabled (i.e QTreeWidgetItem.setDisabled(True) )


回答1:


It is, you'll want to call setSelectionMode during init to enable QAbstractItemView::MultiSelection. QTreeView/QTreeWidget inherit QAbstractItemView, so it is available.

Then to disable the items, just hook on to QTreeWidgets.itemSelectionChanged() signal.




回答2:


I think below will help:

youQTreeWidget.setSelectionMode(QGui.QAbstractView.MultiSelection)


来源:https://stackoverflow.com/questions/6925011/multiple-selection-qtreewidget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!