title: QAbstractItemModel::endInsertRows: Invalid index run time error
body: <p>Greeting, everyone, I'm currently using QTableView to build my c++ GUI project.
  However, when I'm doing adding row into the table, the run time error which is QAbstractItemModel::endInsertRows:  Invalid index  occurs.
  This problem only occurs when I'm selecting last row in my QTableView, is there any solution for this problem? Thanks~</p>
  
  <pre><code>bool TableModel::insertRows(int position, int rows, const QModelIndex &amp;index)
  {
      Q_UNUSED(index);
      beginInsertRows(QModelIndex(), position, position+rows-1);
      endInsertRows();
      return true;
  }
  </code></pre>
  
  <p>submit button click slot:</p>
  
  <pre><code>void MainWindow::on_submitButton_clicked()
  {
      reminder node;
      node.setNote(ui-&gt;noteInput-&gt;toPlainText().toStdString());
      node.setDate(ui-&gt;dateInput-&gt;text().toStdString());
      QModelIndex index = mymodel-&gt;index(0, 0, QModelIndex());
      mymodel-&gt;insertRows(0, 1, index);
      mymodel-&gt;setData(index, node, Qt::EditRole);
      ui-&gt;tableView-&gt;scrollToBottom();
   }
  </code></pre>
  
  <p>setData:</p>
  
  <pre><code> bool TableModel::setData(const QModelIndex &amp;index, const reminder &amp;value, int role)
   {
  
         if (role == Qt::EditRole) {
                  aList.insert(aList.getLength()+1, value); /* aList is a linked List to store reminder */
                  emit(dataChanged(index, index));
                  aList.saveList(listFile);
                  return true;
          }
  
      return false;
    }
  </code></pre>
  
  <p>//edit</p>
  
  <p>thanks everyone, i already solve this question by moving my insert list function into insertRows that, TQVM</p>