title: How to edit selected data/row in QTableView?
body: <p>I have a QTableView and if a user selected a row, i want to change the data in the table by clicking a button. So my problem is, that I don't know how to get the rowindex of the selected row, to give this to the button.</p>
  <p>I have this Dialog:</p>
  <pre><code>ListDialog::ListDialog(QWidget *parent, int listId) :
      QDialog(parent),
      ui(new Ui::ListDialog)
  {
      ui-&gt;setupUi(this);
  
      DbManager conn;
      model = new QSqlQueryModel();
      conn.connOpen();
      QSqlQuery* query = new QSqlQuery(conn.mydb);
      QSqlQuery* query2 = new QSqlQuery(conn.mydb);
  
      query-&gt;prepare(&quot;SELECT f.name AS Name, f.quantityperpack AS Menge_pro_Pack, f.unit AS Einheit, c.amount AS Menge FROM Contains c, Food f WHERE c.ListId=:listId AND c.FoodId = f.FoodId&quot;);
      query-&gt;bindValue(&quot;:listId&quot;, listId);
      query-&gt;exec();
      model-&gt;setQuery(*query);
      ui-&gt;tableView-&gt;setModel(model);
  
  
      query2-&gt;prepare(&quot;SELECT name FROM lists WHERE ListId=:listId AND c.FoodId&quot;);
      query2-&gt;bindValue(&quot;:listId&quot;, listId);
      query2-&gt;exec();
      query2-&gt;next();
      ui-&gt;textBrowser -&gt;setText(query-&gt;value(0).toString());
  
      conn.connClose();
  }
  </code></pre>
  <p>And when I click on this button it should change the value</p>
  <pre><code>void ListDialog::on_pushButton_plus_clicked(){
      //get Index of selected Row
      //add 1 to the amount column in this row
  }
  </code></pre>
  <p>I'm new in qt so thanks for your help.</p>