title: Set an editable column for QTableView
body: <p>I want to set an editable column in <strong>QTableView</strong>, so far I tried to subclass <strong>QTableView</strong> and reimplementing <code>Qt::ItemFlags flags(const QModelIndex &amp; index) const</code>, subclassing <strong>QSqlQueryModel</strong> and reimplementing <code>Qt::ItemFlags flags(const QModelIndex &amp; index) const</code>, finally, subclassing <strong>QAbstractItemView</strong>, but this make a compiler error showed up.</p>
  
  <p>Subclassing QTableView:</p>
  
  <pre><code>#include "exqtableview.h"
  
  ExQTableView::ExQTableView(QWidget *parent) :
      QTableView(parent)
  {
  }
  
  Qt::ItemFlags ExQTableView::flags(const QModelIndex &amp; index) const
  {
      if (!index.isValid())
          return Qt::ItemIsEnabled;
      if (index.column() == 2)
          return index.parent().flags() &amp; ~Qt::ItemIsEditable;
  }
  </code></pre>
  
  <p>Sub classing QSqlQueryModel </p>
  
  <pre><code>#include "exsqlquerymodel.h"
  
  ExSqlQueryModel::ExSqlQueryModel(QObject *parent) :
      QSqlQueryModel(parent)
  {
  }
  
  Qt::ItemFlags ExSqlQueryModel::flags( const QModelIndex &amp;index) const
  {
      Qt::ItemFlags flags = QSqlQueryModel::flags(index);
      if (index.column() == 2 )
          flags &amp;= ~Qt::ItemIsEditable;
      return flags;
  }
  </code></pre>
  
  <p>Sub classing QAbstractItemView</p>
  
  <pre><code>#include "exitemdelegate.h"
  #include &lt;QTableWidgetItem&gt;
  
  ExItemDelegate::ExItemDelegate(QObject *parent) :
      QItemDelegate(parent)
  {
  }
  
  QWidget *ExItemDelegate::createEditor(QWidget *parent,
      const QStyleOptionViewItem &amp; ,
      const QModelIndex &amp; index ) const
  {
      QTableWidgetItem *item = new QTableWidgetItem;
      return item;
  }
  
  void ExItemDelegate::setEditorData(QWidget *editor,
                                       const QModelIndex &amp;index) const
   {
       float value = index.model()-&gt;data(index, Qt::EditRole).toFloat();
  
       QTableWidgetItem *cell = static_cast&lt;QTableWidgetItem*&gt;(editor);
       cell-&gt;setData(0, value);
   }
  
  void ExItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                      const QModelIndex &amp;index) const
   {
       QTableWidgetItem *cell = static_cast&lt;QTableWidgetItem*&gt;(editor);
       float value = cell-&gt;data(Qt::DisplayRole);
       model-&gt;setData(index, value, Qt::EditRole);
   }
  
  void ExItemDelegate::updateEditorGeometry(QWidget *editor,
      const QStyleOptionViewItem &amp;option, const QModelIndex &amp;) const
  {
      editor-&gt;setGeometry(option.rect);
  }
  </code></pre>
  
  <p>Why all of this methods fails to achieve what I want?</p>