I use a QTableWidget as an I/O feature for the user but I want to make it more user friendly and intuitive by disabling the editability of cells which are only for data output.
I can uncheck "Editable" under flags for each individual cell in Qt Designer but as soon as I change the value of a cell with self.table_item.setItem(row, column, QTableWidgetItem(str(value)))
the cells is editable again.
This question/answer suggest using self.table_item.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
, but that changes the flag for the whole QTableWidget item and not only one cell.
I've also tried self.table_time.item(row,column).setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
but I get the traceback 'QTableWidgetItem' object has no attribute 'setEditTriggers'
.
.setFlags()
seems like the function I do need to use but I don't know how to use this to make something not editable or how to apply it to a single cell.
Question:
How can I change the "editable" flag for a individual cell of a QTableWidget in PyQt5 after changing the value of the cells QTableWidgetItem trough .setItem()
.
You will get extra imaginary internet points if you provide an additional solution to make a whole row un-editable in an elegant way.