title: How to delete a row from SQLite database using QSqlQueryModel?
body: <p>I am trying to delete a row from QSqlQueryModel as follows:</p>
  
  <pre><code>void MainWindow::deleteRecord()
  {
      int row_index= ui-&gt;tableView-&gt;currentIndex().row();
      model-&gt;removeRow(row_index);
  }
  </code></pre>
  
  <p>But it is not working.</p>
  
  <p>I tried the following as well:</p>
  
  <pre><code>void MainWindow::deleteRecord()
      {
          int row_index= ui-&gt;tableView-&gt;currentIndex().row();    
          if(!db_manager-&gt;delete_record(QString::number(row_no))){
              ui-&gt;appStatus-&gt;setText("Error: data deletion ...");
          } else{
              ui-&gt;appStatus-&gt;setText("Record deleted ...");
          }
      }
  </code></pre>
  
  <p>Where in db_manager, the function delete_recod(QString row_no) is:</p>
  
  <pre><code>bool DatabaseManager::delete_record(QString row_index)
  {
      QSqlQuery query;
      query.prepare("DELETE FROM personal_Info WHERE ref_no =  (:ref_no)");
      query.bindValue(":ref_no",row_index);
      if (!query.exec())
      {
          qDebug() &lt;&lt; "Error" &lt;&lt; query.lastError().text();
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>But also not working. In both attempts, the application doesn't crash and no SQLite errors. </p>
  
  <p>What am I doing wrong and how can I fix it?</p>