title: Cant get a custom ItemDelegate to work
body: <p>first off, im new to python and pyqt so please bear with me.</p>
  
  <p>Im using a QTableView with a QSqlTableModel everything works as intended.
  The last column of the view contains only 0 and 1 as value which i want to display as checkbox and this column should be editable.</p>
  
  <p>Ive read that you should subclass QItemDelegate which i did. Unluckily my table wont show the last column as a checkbox.</p>
  
  <p>I tried to set the delegate only for the last column (the way i would prefer) using setItemDelegateForColumn(), it didnt work. So i modified it and set it for the entire QTableView using setItemDelegate() reacting only to requests to the last column. It still wont work. Wont work means there are no error messages it just wont do what i say ;) It seems that none of the methods i reimplemented gets ever called except <strong>init</strong>(). So i guess im missing something fundamental.</p>
  
  <p>Ive extracted the relevant lines of code, KSCheckBoxDelegate is my subclass. This is the version where the delegate is set up for the entire QTableView.</p>
  
  <pre><code>
  -- code from applications main class --
  self.taglist = QTableView()
  self.tagmodel = QSqlTableModel()
  self.tagmodel.setTable("data")
  self.tagmodel.select()
  self.taglist.setModel(self.tagmodel)
  print self.taglist.itemDelegate()
  myDel = KSCheckBoxDelegate(self)
  myDel.colnumber = 3
  self.taglist.setItemDelegate(myDel)
  
  
  -- KSCheckBoxDelegate.py --
  from PyQt4.QtGui import *
  
  class KSCheckBoxDelegate(QStyledItemDelegate):
  
      colnumber = None
  
      def __init__ (self, parent = None):
          print "KSCheckBoxDelegate::init"
          QStyledItemDelegate.__init__(self, parent)
  
      def createEditor(self, parent, option, index):
          print "KSCheckBoxDelegate::createEditor"
          if index.column()==self.colnumber:
              return QCheckBox(self)
          else:
              return QStyledItemDelegate.createEditor(self, parent, option, index)
  
      def setEditorData (self, editor, index):
          print "KSCheckBoxDelegate::setEditorData"
          if index.column() == self.colnumber:
              cont = index.model().data(index, Qt.DisplayRole).toString()
              if cont == "1":
                  editor.setCheckState(Qt.Checked)
              else:
                  editor.setCheckState(Qt.UnChecked)
          else:
              QStyledItemDelegate.setEditorData(self,editor, index)
  
      def setModelData (self, editor, model, index):
          print "KSCheckBoxDelegate::setModelData"
          if index.column() == self.colnumber:
              if editor.checkBox.checkState() == Qt.Checked:
                  model.setData(index, 1)
              else:
                  model.setData(index, 0)
          else:
              QStyledItemDelegate.setModelData(self, editor, model, index)
  </code></pre>
  
  <p>Any hints for me on that issue?</p>
  
  <p>Furthermore i have difficulties with the currentChanged() signal of the QTableViews selectionModel. Im printing the top right coordinates of the selection. I keep getting wrong indexes (not invalid) when clicking with the left mouse button. Using the cursor keys gets me the right indexes. Using selectionChanged() has the same behaviour. Im actually getting the coordinates of the second last selected cell of the QTableView. For instance im clicking on the coordinates &lt;1,1> &lt;2,1> the second click would show me the coordinates &lt;1,1>.</p>
  
  <pre><code>
  selInd = self.taglist.selectionModel().selectedIndexes()
  if(len(selInd) > 0):
      self.xPosData=selInd[0].column()
      self.yPosData=selInd[0].row()
  </code></pre>
  
  <p><b>Fixed that by myself, with using QTableView.currentIndex() instead of selectionModel.selectedIndexes()</b> :)</p>
  
  <p>And last off using OnManualSubmit as editStrategy doesnt throw an error (return false) when calling submitAll() but doesnt save the data either. It works with choosing OnFieldChange as editStrategy. Which i can live with but is not was i have intended to do.</p>
  
  <p>Thanks for your time.</p>
  
  <p>Horst</p>