title: Qt - How to Remove the selected Row from the QTableView and copy it to the QLineEdit
body: <p>I have 3 <code>QLineEdit</code>s (say Name, Address &amp; Phone No.), 2 <code>QPushButton</code> (Add &amp; Modify) and a <code>QTableView</code>. </p>
  
  <p>When I enter text in all the <code>QLineEdit</code>s, and if I click the Add button, all 3 texts of the <code>QLineEdit</code>s should be added in the 1st row of the <code>QTableView</code>.<br>
  Again if I enter 3 text's in the <code>QLineEdit</code> and the Add Button is Clicked, the Text's should be placed in the 2nd row of the <code>QTableView</code>. Like this it should go on. I did this all and it works fine. </p>
  
  <p>Now if I select any row from the <code>QTableView</code> and once I click the Modify Button the selected Row has to be removed from the <code>QTableView</code> and the Items should be again placed in their respective <code>QLineEdit</code>s. </p>
  
  <p>How can I do this ?</p>
  
  <p>Example.h</p>
  
  <pre><code>#ifndef EXAMPLE_H
  #define EXAMPLE_H
  
  #include &lt;QWidget&gt;
  #include &lt;QStandardItemModel&gt;
  
  namespace Ui {
  class Example;
  }
  
  class Example : public QWidget
  {
      Q_OBJECT
  
  public:
      explicit Example (QWidget *parent = 0);
      ~Example();
  
  private slots:
      void on_addButton_released();
      void on_modifyButton_released();
  
  private:
      Ui::Example*ui;
      QStandardItemModel *model;
  };
  
  #endif // EXAMPLE_H
  </code></pre>
  
  <p>EXAMPLE.CPP</p>
  
  <pre><code>#include "Example.h"
  
  Example::Example(QWidget *parent) :
      QWidget(parent),
      ui(new Ui::Example)
  {
      ui-&gt;setupUi(this);
      model = new QStandardItemModel();
  
      ui-&gt;tableView-&gt;setModel(model);
  
  }
  
  Example::~Example()
  {
      delete ui;
  }
  
  void Example::on_addButton_released()
  {
      model-&gt;setHorizontalHeaderItem(0, new QStandardItem(QString(" NAME ")));
      model-&gt;setHorizontalHeaderItem(1, new QStandardItem(QString(" ADDRESS ")));
      model-&gt;setHorizontalHeaderItem(2, new QStandardItem(QString(" PHONE NO ")));
  
      QStandardItem *nameItem = new QStandardItem(ui-&gt;nameLineEdit-&gt;text());
      QStandardItem *addressItem = new QStandardItem(ui-&gt;addressLineEdit-&gt;text());
      QStandardItem *phoneItem = new QStandardItem(ui-&gt;phoneLineEdit-&gt;text());
  
      QList&lt;QStandardItem*&gt; row;
      row &lt;&lt; nameItem &lt;&lt; addressItem &lt;&lt; phoneItem;
  
      model-&gt;appendRow(row);
  
      ui-&gt;nameLineEdit-&gt;clear();
      ui-&gt;addressLineEdit-&gt;clear();
      ui-&gt;mobileLineEdit-&gt;clear();
      ui-&gt;emailLineEdit-&gt;clear();
  }
  
  void Example::on_modifyButton_released()
  {
  
  
  }
  </code></pre>