Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a QTableWidgetItem with flags()

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)

like image 351
Heini Avatar asked Jul 10 '26 03:07

Heini


1 Answers

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.

like image 59
eyllanesc Avatar answered Jul 11 '26 20:07

eyllanesc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!