In PyQt how can I force a QTableWidget
to only accept a single section (so that you can't select more items with Shift or crtl)?
Asked
Active
Viewed 4,197 times
3

royatirek
- 2,437
- 2
- 20
- 34

user2339945
- 623
- 1
- 9
- 14
1 Answers
5
You need to call QAbstractItemBiew.setSelectionMode()
or your QTableWidget
with the appropriate SelectionBehavior
, in your case QAbstractItemView.SingleSelection
.
So something along the lines of:
myTable = QtGui.QTableWidget()
myTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
-
1Note in pyqt5 QAbstract was moved to QtWidgets – AlexGeorg Oct 07 '21 at 15:38