Making only one column of a QTreeWidgetItem editable

后端 未结 10 1116
无人共我
无人共我 2020-12-06 04:18

I have a QTreeWidgetItem with two columns of data, is there any way to make only the second column editable? When I do the following:

QTreeWidge         


        
10条回答
  •  一生所求
    2020-12-06 04:52

    I'm new to PySide and Python in general, but I was able to get this to work by registering with the QTreeWidget for itemClicked callbacks. Within the callback, check the column and only call 'editItem' if it's for a column you want to allow editing.

    class Foo(QtGui.QMainWindow):
    ...
    def itemClicked(self, item, column):
       if column > 0:
          self.qtree.editItem(item, column)
    

    By not invoking editItem for column 0, the event is basically discarded.

提交回复
热议问题