Create a QTableWidgetItem with flags()

拈花ヽ惹草 提交于 2021-02-05 05:58:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!