问题
I dont understand the Qt5 Documentation in the TableWidgetItem-Chapter. I cant get the right parameters to set my freshly created TableCell as editable. I've got this piece of code
for i, item in enumerate(event_desc, start=0):
print(i, item)
key = QTableWidgetItem(list(event_desc)[i])
value = QTableWidgetItem(event_desc[item])
value.setFlags( * what's to insert here? * )
tw.insertRow(i)
tw.setItem(i, 0, key)
tw.setItem(i, 1, value)
The first param should be *self, the 2nd one is named 'Union' (What does this mean? i cant go further, this param is missing)
回答1:
If you must set a QTableWidgetItem as editable you must do:
value.setFlags(value.flags() | QtCore.Qt.ItemIsEditable)
The operator |
allows to enable a flag, and instead the operation & ~
disables them.
来源:https://stackoverflow.com/questions/58124062/create-a-qtablewidgetitem-with-flags