title: Remove rows from QAbstractListModel
body: <p>I have a custom model which derives from QAbstractListModel which is exposed to QML. I need to support operations to add new items and remove existing items. While insertion operation works without any problems, removal operation causes the application to crash while calling endRemoveRows() function.</p>
  
  <pre><code>    void GPageModel::addNewPage()
      {
          if(m_pageList.count()&lt;9)
          {
              beginInsertRows(QModelIndex(),rowCount(),rowCount());
              GPage * page = new GPage();
              QQmlEngine::setObjectOwnership(page,QQmlEngine::CppOwnership);
              page-&gt;setParent(this);
              page-&gt;setNumber(m_pageList.count());
              page-&gt;setName("Page " + QString::number(m_pageList.count()+1));
              m_pageList.append(page);
              endInsertRows();
          }
      }
  
      void GPageModel::removePage(const int index)
      {
          if(index&gt;=0 &amp;&amp; index&lt;m_pageList.count())
          {        
              beginRemoveRows(QModelIndex(),index,index);
              qDebug()&lt;&lt;QString("beginRemoveRows(QModelIndex(),%1,%1)").arg(index);
              GPage * page = m_pageList.at(index);        
              m_pageList.removeAt(index);
              delete page;
              endRemoveRows();
          }
      }
  </code></pre>
  
  <p>The class GPage derives from QObject. I am struck trying to figure out what is causing the app to crash while trying to call endRemoveRows(). I get "ASSERT failure in QList::at: "index out of range"" when endRemoveRows() is called.How do I remove the rows from a QAbstracListModel? Is there any other way?</p>
  
  <p>I am using Qt 5.1.0 on a Windows 7 64 bit machine.</p>