title: How to Move Up a Selected Row in Qt
body: <p>I have a <code>QTableView</code> with 3 rows and 2 columns. (Here I am using a <code>QStandardItemModel</code>). I want to move up/move down a single row when a QPushButton is clicked. How can I move up/down a row in <code>QTableView</code>?</p>
  
  <p>Thanks for your reply vahancho. I have already tried using <code>QAbstractItemModel::moveRow</code>, but it doesn't work:</p>
  
  <pre><code>   int currentRow = ui-&gt;tableView-&gt;currentIndex().row();
     QModelIndex sourceParent = ui-&gt;tableView-&gt;model()-&gt;index(ui-&gt;tableView-&gt;selectionModel()-&gt;currentIndex().row(),0);
     QModelIndex destinationParent = ui-&gt;tableView-&gt;model()-&gt;index(ui-&gt;tableView-&gt;selectionModel()-&gt;currentIndex().row()+1,0);
     ui-&gt;tableView-&gt;model()-&gt;moveRow(sourceParent,currentRow, destinationParent,destinationParent.row());
  </code></pre>