title: Updating QTableView with more rows dynamically
body: <p>I have a <code>QTableView</code>, which uses a model derived from <code>QAbstractTableModel</code>.</p>
  
  <p>The model starts out with a number of rows and displays the data properly.</p>
  
  <p>The model also has a timer attached to it, which upon expiring, gets the number of rows and columns, constructs an index for it, and emits dataChanged signal, to update the dynamic contents of the table.</p>
  
  <p>The problem is when the number of rows it is supposed to display, changes.</p>
  
  <p>In that case, even though I obtain a new index with the changed no. of rows, and update the table, it still doesn't display any new rows.</p>
  
  <p>I've identified why, perhaps. Let's say I have 2 rows in the beginning, and next, 5 rows are supposed to be displayed. In the timer expiration logic, I've asked it to construct a new index, with new row count… but <code>dataChanged()</code> signal, will only change the data for the rows which had already been inserted in the first. The new rows are not displayed.</p>
  
  <p>This is my code for the model. </p>
  
  <pre><code>TableLayout::TableLayout()
    : QAbstractTableModel()
  {
    rowCount();
    columnCount();
    timer = new QTimer(this);
    timer-&gt;setInterval(3000);
    timer-&gt;start();
    connect(timer, SIGNAL(timeout()), this, SLOT(timerHit()));
  
    //ItemList[0].SetFields("Blah" ,"Blah" , "Blah" , "Blah" , "Blah", "Blah", true  );
    //ItemList[1].SetFields("Blah1" ,"Blah1" ,"Blah1" ,"Blah1" ,"Blah1", "Blah1", true );
  }
  
  void TableLayout::timerHit()
  {
    int row = this-&gt;rowCount();
    qDebug() &lt;&lt; "RowCOunt::" &lt;&lt; row;
    qDebug() &lt;&lt; " Now IT IS : " &lt;&lt; row;
    int col = this-&gt;columnCount();
    qDebug() &lt;&lt; "ColumnCOunt::" &lt;&lt; col;
    QModelIndex Ind = createIndex( 0, 0);
    QModelIndex Ind1 = createIndex( row, col);
    data(Ind1);
    emit dataChanged(Ind, Ind1);
  }
  
  int TableLayout::rowCount(const QModelIndex&amp; /*parent*/) const
  {
    RtdbReader* rtdbReader = RtdbReader::instance();
    if (isConnected)
      return rtdbReader-&gt;Get_Number_of_Items();
    else return 2;
  }
  
  int TableLayout::columnCount(const QModelIndex&amp; /*parent*/) const
  {
    return 6;
  }
  
  QVariant TableLayout::data(const QModelIndex&amp; index, int role) const
  {
    int row = index.row();
    int col = index.column();
  
    //return row;
    int row_count, col_count = 0;
    if ( role == Qt::DisplayRole) {
  
      if ( col == 1)
        return ItemList[row]-&gt;GetExplanation();
      if ( col == 2) {
        qDebug() &lt;&lt; " Now printing Sig name for row" &lt;&lt; index.row();
        return ItemList[row]-&gt;GetCond_Sig_Name();
      }
      if ( col == 3)
        return ItemList[row]-&gt;GetDescription();
      if ( col == 5)
        return ItemList[row]-&gt;GetLogic();
      if ( col == 4)
        return ItemList[row]-&gt;Get_State_Text();
    } else if ( role == Qt::DecorationRole &amp;&amp; col == 0 ) {
      bool col_to_display = ItemList[row]-&gt;GetValueColour();
      qDebug() &lt;&lt; "colour in view:" &lt;&lt; col_to_display;
      if  ( col_to_display ) {
        QString path = "Green.png";
        //QPixmap p( s_type1Icon );
        // return s_type1Icon;
  
        QIcon icon ( path );
        return icon;
      } else {
        QString path = "Yellow.png";
        //QPixmap p( s_type1Icon );
        // return s_type1Icon;
  
        QIcon icon ( path );
        return icon;
      }
    }
  
    if (role == Qt::TextAlignmentRole )
      return Qt::AlignCenter | Qt::AlignVCenter;
  
    /* else if ( role == Qt::BackgroundRole)
     {
       QBrush yellowBackground(Qt::yellow);
                return yellowBackground;
     }*/
  
    return QVariant();
  }
  </code></pre>
  
  <p>Please suggest how I can change the view so new rows are added.</p>
  
  <p>Thanks.</p>