title: Set a whole column in `QTableWidget` read-only in python
body: <p>i want to set a column in my table to read-only! i tried all possible combinations of flags without success</p>
  <pre><code>    item = QtGui.QTableWidgetItem()
      from operator import xor
      item.setFlags(xor(item.flags(),QtCore.Qt.ItemIsEditable))
      self.Table.setHorizontalHeaderItem(4, item)
  </code></pre>
  <p>i also tried <code>and not</code>, <code>!=</code> and <code>^</code> operators but the column items are still editable</p>
  <hr />
  <h1>Update</h1>
  <p>I think i was misunderstanding this! i thought when i set the HorizontalHeaderItem at a column to be not editable, that will make all new items in that column to be automatically not editable, when using the operations like <code>insertRow()</code></p>
  <p>I had perform these function to each new added item after inserting new row!</p>
  <pre><code>        tableWidget.insertRow(row+1)
          if  tableWidget is self.myTable:
              item = QtGui.QTableWidgetItem()
              item.setFlags(item.flags() != QtCore.Qt.ItemIsEditable)
              tableWidget.setItem(row+1, 4, item)
  </code></pre>
  <p>I think a better (but more complex) solution is to use <code>setItemDelegateForColumn()</code> and <code>QtGui.QItemDelegate()</code> to create a read-only costum <code>QTableWidgetItem</code> which will be added each time a new row is inserted or created</p>
  <hr />
  <h1>Edit</h1>
  <p>Well i tried to use <code>setItemDelegateForColumn()</code> and <code>QtGui.QItemDelegate()</code> as mentioned above but i got the following Warning</p>
  <pre><code>&gt; python main.py
  sys:1: RuntimeWarning: Invalid return value in function QItemDelegate.createEdit
  or, expected PySide.QtGui.QWidget, got PySide.QtGui.QTableWidgetItem.
  </code></pre>
  <p>My code for that was</p>
  <pre><code>class QTableWidgetDisabledItem(QtGui.QItemDelegate):
      &quot;&quot;&quot;
      &quot;&quot;&quot;
      def __init__(self, parent):
  
          QtGui.QItemDelegate.__init__(self, parent)
  
      def createEditor(self, parent, option, index):
          item = QtGui.QTableWidgetItem()
          item.setFlags(item.flags() != QtCore.Qt.ItemIsEditable)
          return item
  
      def setEditorData(self, editor, index):
          editor.blockSignals(True)
          editor.setData(index, editor.text())
          editor.blockSignals(False)
  
      def setModelData(self, editor, model, index):
          model.setData(index, editor.text())
  </code></pre>
  <p>and in the MainWindow</p>
  <pre><code>    self.Size = QTableWidgetDisabledItem(self.MyTable)
      self.MyTable.setItemDelegateForColumn(4,self.Size)
  </code></pre>
  <p>It was good idea though ...</p>