I create a QTableWidget with:
self.table = QtGui.QTableWidget()
self.table.setObjectName('table')
self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
verticalLayout.addWidget(self.table)
with this selection it is possible to select rows but I don't want that the user can edit any cells of this table. I know that you can enable each cell while filling the table. But is there a possibility to set the cells of the whole table kind of inactive (after the filling of the table) while the selection of the rows is still possible?
TIA Martin
use
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
(here you can find other triggers, just in case you need them)
You can disable editing by setting the flags ItemIsSelectable
and ItemIsEnabled
for each item in your table:
table = QTableWidget(10,10)
for i in range(10):
for j in range(10):
item = QTableWidgetItem(str(i*j))
item.setFlags( Qt.ItemIsSelectable | Qt.ItemIsEnabled )
table.setItem(i, j, item)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With