title: QTableView external drag and drop
body: <p>Is there a way to drag rows out of a QTableView?</p>
  
  <p>I know how to internally move columns within a <code>QTableView</code> by configuring some properties on the view:</p>
  
  <pre><code>table_view_-&gt;horizontalHeader()-&gt;setSectionsMovable(true);
  table_view_-&gt;horizontalHeader()-&gt;setDragEnabled(true);
  table_view_-&gt;horizontalHeader()-&gt;setDragDropMode(QAbstractItemView::InternalMove);
  </code></pre>
  
  <p>Going through the documentation on <code>QAbstractItemView::DragDropMode</code>, I intuitively expected my following attempt to allow external dragging of vertical header items:</p>
  
  <pre><code>table_view_-&gt;verticalHeader()-&gt;setSectionsMovable(true);
  table_view_-&gt;verticalHeader()-&gt;setDragEnabled(true);
  table_view_-&gt;verticalHeader()-&gt;setDragDropMode(QAbstractItemView::DragOnly);
  </code></pre>
  
  <p>Still, I am limited to only internal move.</p>
  
  <p>Given <a href="https://doc.qt.io/archives/4.6/model-view-dnd.html" rel="nofollow" title="acticlequot;">this article</a> I derived my own model from <code>QSqlRelationalTableModel</code> and added the <code>Qt::ItemIsDragEnabled</code> flag to the <code>flags</code> function, for all vertical header indexes:</p>
  
  <pre><code>Qt::ItemFlags MyRelationalTableModel::flags(const QModelIndex &amp;index) const
  {
      Qt::ItemFlags defaultFlags = QSqlRelationalTableModel::flags(index);
  
      if(index.column() == -1 &amp;&amp; index.row() &gt; -1) {
          qDebug() &lt;&lt; "drag enabled.";
          return Qt::ItemIsDragEnabled | defaultFlags;
      } else {
          qDebug() &lt;&lt; "not drag enabled.";
      }
  
      return defaultFlags;
  }
  </code></pre>
  
  <p>This didn't change anything and given the debug prints, <code>flags</code> wasn't even called for vertical header items.</p>