title: How to add a QString to a QListView using a QLineEdit
body: <p>I want to use a QLineEdit to write a QString, then using a QPushButton, I want to add an item (a string) to a listView</p>
  
  <p>Here is what I got:</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui-&gt;setupUi(this);
  
      model = new QStringListModel(this);
  
      QStringList list;
  
      list &lt;&lt; "Some Item";
  
      model-&gt;setStringList(list);
  
      ui-&gt;listView-&gt;setModel(model);
      ui-&gt;listView-&gt;setEditTriggers(QAbstractItemView::NoEditTriggers);
  }
  
  void MainWindow::on_pushButton_3_clicked()
  {
      //add
      int row = model-&gt;rowCount();   // model = new QStringListModel
      model-&gt;insertRow(row);
  
      QModelIndex index = model-&gt;index(row);
      ui-&gt;listView-&gt;setCurrentIndex(index);
      ui-&gt;listView-&gt;edit(index);  // instead of edit, I'd like to ... add a QString
  }
  </code></pre>
  
  <p>Problem is I don't want to be able to edit (this was all I was manage to do by myself). I want now to instead add an item at CurrentIndex, and that item to be the text field of <code>lineEdit</code>. How do I get access to that field ? is it <code>lineEdit-&gt;text()</code> ? and how do I add that to the list view ?</p>
  
  <p>I simply do not know how to add anything to a list. I found edit by mistake, and google has not helped so far. I'm hoping Stack Overflow can, and will.</p>
  
  <p><strong>EDIT:</strong> I have decided to try this, but it doesn't seem to be the best solution</p>
  
  <pre><code>void MainWindow::on_pushButton_3_clicked()
  {
      //add
  
      QStringList list;
      list = model-&gt;stringList();
      list.append(ui-&gt;lineEdit-&gt;text());
      model-&gt;setStringList(list);
  }
  </code></pre>
  
  <p>But this seems to be an odd way of doing things. Also it seems to include a newline for some reason.</p>